Skip to content

Commit beac8dc

Browse files
committed
Fix up-to-date check not working when making patches with the same Git version as the patch
1 parent 09870f3 commit beac8dc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ plugins {
1212
}
1313

1414
group = 'net.minecrell'
15-
version = '0.5.1'
15+
version = '0.5.2'
1616
description = 'A Gradle plugin to manage patches for Git repositories'
1717

1818
sourceCompatibility = 1.6

src/main/groovy/net/minecrell/gitpatcher/task/patch/MakePatchesTask.groovy

+12-5
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,21 @@ class MakePatchesTask extends PatchTask {
7171
def first = diff.findIndexOf(HUNK)
7272
if (first >= 0 && diff[first + 1].startsWith('From', 1)) {
7373
def last = diff.findLastIndexOf(HUNK)
74-
if (last >= 0 && diff[last + 1].startsWith('--', 1)) {
74+
boolean upToDate = false
75+
if (first == last) { // There is just one hunk, so probably just the hash changed
76+
upToDate = true
77+
} else if (last >= 0 && diff[last + 1].startsWith('--', 1)) {
7578
if (!diff.subList(first + 4, last).find(HUNK)) {
76-
logger.lifecycle 'Skipping {} (up-to-date)', patch.name
77-
git.reset('HEAD', patch.absolutePath) >> null
78-
git.checkout('--', patch.absolutePath) >> null
79-
continue
79+
upToDate = true
8080
}
8181
}
82+
83+
if (upToDate) {
84+
logger.lifecycle 'Skipping {} (up-to-date)', patch.name
85+
git.reset('HEAD', patch.absolutePath) >> null
86+
git.checkout('--', patch.absolutePath) >> null
87+
continue
88+
}
8289
}
8390

8491
didWork = true

0 commit comments

Comments
 (0)