File tree 1 file changed +10
-2
lines changed
src/main/groovy/com/alexvasilkov/vcs/util
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,9 @@ class GitHelper {
22
22
}
23
23
24
24
String targetCommit = repo. commit
25
- String localCommit = git. head(). id
26
25
27
- if (repo. keepUpdated && ! localCommit. startsWith(targetCommit)) {
26
+ if (repo. keepUpdated && ! isLocalCommit(git, targetCommit)) {
27
+ String localCommit = git. head(). id
28
28
println " Git local version '${ localCommit} ' is not eqaul to target " +
29
29
" '${ targetCommit} ' for '${ repo.repoDir} '"
30
30
@@ -55,6 +55,14 @@ class GitHelper {
55
55
.getString(' remote' , Constants . DEFAULT_REMOTE_NAME , ' url' )
56
56
}
57
57
58
+ private static boolean isLocalCommit (Grgit git , String targetId ) {
59
+ def head = git. head()
60
+ // Checking if local commit is equal to (starts with) requested one.
61
+ // If not then we should check if there are tags with target name pointing to current head.
62
+ return head. id. startsWith(targetId) ||
63
+ git. tag. list(). find { it. commit == head && it. name == targetId }
64
+ }
65
+
58
66
private static boolean hasLocalChanges (Grgit git ) {
59
67
Status status = git. status()
60
68
return ! status. staged. allChanges. isEmpty() || ! status. unstaged. allChanges. isEmpty()
You can’t perform that action at this time.
0 commit comments