Skip to content

Commit

Permalink
Check if a tag or branch is checked out by Antora
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Oct 30, 2023
1 parent c82e600 commit 5b4e613
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ buildscript {
// TODO: remove these hacks once jgit supports worktrees (nebula upgrades) and/or Antora supports full-clone
if (project.hasProperty('antora')) {
'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)
String tag = 'git tag --points-at HEAD'.execute().text.trim() // jgit does not able to figure out tags in Antora's worktree
if (tag) {
println "Found release tag: $tag, using it as release.version"
ext['release.version'] = tag.substring(1)
String ref = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
if (ref == 'HEAD') { // if Antora checks out a tag instead of a branch
String tag = 'git tag --points-at HEAD'.execute().text.trim() // jgit is not able to figure out tags in Antora's worktree
if (tag) {
println "Found release tag: $tag, using it as release.version"
ext['release.version'] = tag.substring(1)
}
}
// We need to tell the location of the .git folder since jgit does not support worktrees
ext['git.root'] = 'git rev-parse --path-format=absolute --git-common-dir'.execute().text.trim()
Expand Down

0 comments on commit 5b4e613

Please sign in to comment.