Skip to content

Commit c6d9433

Browse files
committed
Harden git version tag parsing
1 parent 2b4999f commit c6d9433

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

version.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ try {
5555
// If the commit is an exact match then this returns just the tag
5656
// name, else it returns tagName-commitCount-abbreviatedId.
5757
def describe = gitOutput(['describe', '--tags', '--abbrev=7', 'HEAD'])
58-
def fullDescribe = (describe =~/(.*?)-(\d+)-g$jmeShortGitHash/)
58+
def fullDescribe = (describe =~/(.*?)-(\d+)-g${jmeShortGitHash}[0-9a-f]*/)
5959
latestTag = fullDescribe ? fullDescribe[0][1] : describe
6060
println "Latest tag:" + latestTag
6161
}
6262

6363
// We could enhance this with some more regex if we wanted to sanity
6464
// check that it was formatted like our versions.
65-
def tagVersion = latestTag ? (latestTag =~/v?(.*)/)[0][1] : jmeVersion;
65+
def tagVersion = latestTag ? latestTag.replaceFirst(/^v/, "") : jmeVersion;
6666
// If the branch is not master then use the tag.
6767
if( jmeBranchName != "master" && latestTag ) {
6868
jmeVersion = tagVersion

0 commit comments

Comments
 (0)