Skip to content

Commit c3f3970

Browse files
authored
Merge branch 'master' into update_kotlin_to_java_diff_utils_4_11
2 parents 4301d03 + 98095e7 commit c3f3970

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

.github/workflows/pull_request.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,65 @@ jobs:
1212
with:
1313
java-version: 1.8
1414

15+
- name: Short SHA
16+
env:
17+
COMMIT_SHA: ${{github.event.pull_request.head.sha}}
18+
run: echo "short_sha=${COMMIT_SHA::7}" >> $GITHUB_ENV
19+
1520
- name: Read version
1621
id: read_version
1722
uses: reedyuk/read-properties@v1.0.0
1823
with:
1924
path: 'gradle.properties'
2025
property: 'version'
26+
27+
- name: Update version
28+
uses: reedyuk/write-properties@v1.0.0
29+
with:
30+
path: 'gradle.properties'
31+
property: 'version'
32+
value: "${{ steps.read_version.outputs.value }}-${{ github.head_ref }}-${{ env.short_sha }}"
33+
2134
- name: Change package version
2235
uses: eskatos/gradle-command-action@v1
2336
with:
2437
arguments: updateVersion
38+
2539
- name: Build
2640
uses: eskatos/gradle-command-action@v1
2741
with:
2842
arguments: build
43+
2944
- name: Test
3045
uses: eskatos/gradle-command-action@v1
3146
with:
3247
arguments: jvmTest
48+
3349
- name: Test Report
3450
uses: scacap/action-surefire-report@v1
3551
if: always()
3652
with:
3753
report_paths: "build/test-results/jvmTest/*.xml"
3854
github_token: ${{ secrets.GITHUB_TOKEN }}
55+
3956
- name: Publish
4057
uses: eskatos/gradle-command-action@v1
4158
with:
4259
arguments: publishAllPublicationsToGitHubPackagesRepository
4360
env:
4461
TOKEN: ${{ secrets.AUTO_TOKEN }}
4562
USERNAME: ${{ secrets.AUTO_USERNAME }}
63+
4664
- name: Setup NPM
4765
run: npm config set //npm.pkg.github.com/:_authToken=$token
4866
env:
4967
token: ${{ secrets.GITHUB_TOKEN }}
68+
5069
- name: Setup package name
5170
uses: eskatos/gradle-command-action@v1
5271
with:
5372
arguments: prepareForGithubNpmPublish
73+
5474
- name: Publish npm
5575
uses: eskatos/gradle-command-action@v1
5676
with:

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
version=5.1.5-0fd38db
2-
kotlin_version = 1.5.32
1+
version=4.11.5-0fd38db
2+
kotlin_version=1.5.32
33
kotlinx-coroutines.version=1.5.2
44

55
kotlin.code.style=official

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
},
2727
"homepage": "https://github.com/GitLiveApp/kotlin-diff-utils#readme",
2828
"dependencies": {
29-
"kotlin": "1.5.30"
29+
"kotlin": "1.5.32"
3030
}
3131
}

src/commonMain/kotlin/dev/gitlive/difflib/UnifiedDiffUtils.kt

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ object UnifiedDiffUtils {
176176
// position.
177177
// And if it is, add it to the current set
178178
val nextDelta = patchDeltas[i]
179-
if (position + delta.source.size() + contextSize >= nextDelta
180-
.source.position - contextSize
181-
) {
179+
if (position + delta.source.size() + contextSize >= nextDelta.source.position - contextSize) {
182180
deltas.add(nextDelta)
183181
} else {
184182
// if it isn't, output the current set,
@@ -248,7 +246,6 @@ object UnifiedDiffUtils {
248246
// output the context before the first Delta
249247
line = contextStart
250248
while (line < curDelta.source.position) {
251-
//
252249
buffer.add(" " + origLines[line])
253250
origTotal++
254251
revTotal++
@@ -262,13 +259,9 @@ object UnifiedDiffUtils {
262259
var deltaIndex = 1
263260
while (deltaIndex < deltas.size) { // for each of the other Deltas
264261
val nextDelta = deltas[deltaIndex]
265-
val intermediateStart = (curDelta.source.position
266-
+ curDelta.source.lines.size)
262+
val intermediateStart = (curDelta.source.position + curDelta.source.lines.size)
267263
line = intermediateStart
268-
while (line < nextDelta.source
269-
.position
270-
) {
271-
264+
while (line < nextDelta.source.position) {
272265
// output the code between the last Delta and this one
273266
buffer.add(" " + origLines[line])
274267
origTotal++
@@ -283,8 +276,7 @@ object UnifiedDiffUtils {
283276
}
284277

285278
// Now output the post-Delta context code, clamping the end of the file
286-
contextStart = (curDelta.source.position
287-
+ curDelta.source.lines.size)
279+
contextStart = (curDelta.source.position + curDelta.source.lines.size)
288280
line = contextStart
289281
while (line < contextStart + contextSize
290282
&& line < origLines.size
@@ -295,19 +287,8 @@ object UnifiedDiffUtils {
295287
line++
296288
}
297289

298-
// Create and insert the block header, conforming to the Unified Diff
299-
// standard
300-
val header = StringBuilder()
301-
header.append("@@ -")
302-
header.append(origStart)
303-
header.append(",")
304-
header.append(origTotal)
305-
header.append(" +")
306-
header.append(revStart)
307-
header.append(",")
308-
header.append(revTotal)
309-
header.append(" @@")
310-
buffer.add(0, header.toString())
290+
// Create and insert the block header, conforming to the Unified Diff standard
291+
buffer.add(0, "@@ -$origStart,$origTotal +$revStart,$revTotal @@")
311292
return buffer
312293
}
313294

0 commit comments

Comments
 (0)