File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
main/kotlin/cc/unitmesh/devti/vcs
test/kotlin/cc/unitmesh/devti/prompting/diff Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,15 @@ class DiffSimplifier(val project: Project) {
247
247
248
248
val startLine = substringBefore
249
249
.substring(" --- a/" .length).trim()
250
- val withoutEnd = nextLine.substring(" +++ b/" .length, nextLine.indexOf(" (date" )).trim()
250
+ var endIndex = nextLine.indexOf(" (date" )
251
+ if (endIndex == - 1 ) {
252
+ endIndex = nextLine.indexOf(" (revision" )
253
+ }
254
+ if (endIndex == - 1 ) {
255
+ endIndex = nextLine.length
256
+ }
257
+
258
+ val withoutEnd = nextLine.substring(" +++ b/" .length, endIndex).trim()
251
259
252
260
if (startLine == withoutEnd) {
253
261
index + = 2
Original file line number Diff line number Diff line change @@ -123,4 +123,33 @@ change import from com.thoughtworks.archguard.code.module.domain.dubbo.ServiceCo
123
123
""" modify file server/src/test/kotlin/com/thoughtworks/archguard/code/clazz/domain/CodeTreeTest.kt"""
124
124
)
125
125
}
126
+
127
+ @Test
128
+ fun testHandleForRealWorld () {
129
+ val code = """ Index: src/main/java/cc/unitmesh/untitled/demo/controller/BlogCategoryController.java
130
+ ===================================================================
131
+ diff --git a/src/main/java/cc/unitmesh/untitled/demo/controller/BlogCategoryController.java b/src/main/java/cc/unitmesh/untitled/demo/controller/BlogCategoryController.java
132
+ --- a/src/main/java/cc/unitmesh/untitled/demo/controller/BlogCategoryController.java (revision 9b4b04de55fe5be5372eae67987b27f7d329e1f3)
133
+ +++ b/src/main/java/cc/unitmesh/untitled/demo/controller/BlogCategoryController.java (revision 768efa678ecb9c044aea7c5c4873ed218357773b)
134
+ @@ -6,7 +6,5 @@
135
+ public class BlogCategoryController {
136
+ // devti://story/github/1
137
+
138
+ - // 银行账户管理
139
+ -
140
+ // Close a bank account
141
+ }"""
142
+
143
+ val postProcess = DiffSimplifier .postProcess(code)
144
+ assertEquals(
145
+ postProcess,
146
+ """ modify file src/main/java/cc/unitmesh/untitled/demo/controller/BlogCategoryController.java
147
+ public class BlogCategoryController {
148
+ // devti://story/github/1
149
+ - // 银行账户管理
150
+ -
151
+ // Close a bank account
152
+ }"""
153
+ )
154
+ }
126
155
}
You can’t perform that action at this time.
0 commit comments