Skip to content

Commit 5b4e613

Browse files
Check if a tag or branch is checked out by Antora
1 parent c82e600 commit 5b4e613

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

build.gradle

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ buildscript {
3333
// TODO: remove these hacks once jgit supports worktrees (nebula upgrades) and/or Antora supports full-clone
3434
if (project.hasProperty('antora')) {
3535
'git fetch --unshallow --all --tags'.execute().text // Antora shallow-clones so there is no history (we need commit history to find the last tag in the tree)
36-
String tag = 'git tag --points-at HEAD'.execute().text.trim() // jgit does not able to figure out tags in Antora's worktree
37-
if (tag) {
38-
println "Found release tag: $tag, using it as release.version"
39-
ext['release.version'] = tag.substring(1)
36+
String ref = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
37+
if (ref == 'HEAD') { // if Antora checks out a tag instead of a branch
38+
String tag = 'git tag --points-at HEAD'.execute().text.trim() // jgit is not able to figure out tags in Antora's worktree
39+
if (tag) {
40+
println "Found release tag: $tag, using it as release.version"
41+
ext['release.version'] = tag.substring(1)
42+
}
4043
}
4144
// We need to tell the location of the .git folder since jgit does not support worktrees
4245
ext['git.root'] = 'git rev-parse --path-format=absolute --git-common-dir'.execute().text.trim()

0 commit comments

Comments
 (0)