Skip to content

Commit

Permalink
build(#6): fix building with Gradle died after the first beta release (
Browse files Browse the repository at this point in the history
…#8)

* Handle `vx.y.z-beta-N-gabcdef123` in `gitDescribeTag()`

Signed-off-by: iusmac <[email protected]>

* Fix `gitDescribeTag()` docs

Signed-off-by: iusmac <[email protected]>

---------

Signed-off-by: iusmac <[email protected]>
  • Loading branch information
iusmac authored Apr 9, 2024
1 parent e3b8665 commit 33b6122
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,17 @@ kapt {
* Describe the tag relative to a commit-ish using "git describe".
*
* The result from the git describe command will be transformed as follows:
* "TAG-N-g<commit-ish>" = ["TAG", "N", "commit-ish"]
* "<commit-ish>" = [null, 0, "commit-ish"]
* ["TAG", "N", "commit-ish"]
*/
def gitDescribeTag(final String pattern, final String commitIsh) {
final def describedTag = String.format('git describe --always --tags --match=%s %s', pattern,
commitIsh).execute([], project.rootDir).text.trim().split('-')
final def tag, commitsSinceLastTag
final def describedTag = String.format('git describe --always --tags --long --match=%s %s',
pattern, commitIsh).execute([], project.rootDir).text.trim().split('-')
def headCommit
if (describedTag.size() > 1) {
tag = describedTag[0..-3].join('-')
(commitsSinceLastTag, headCommit) = describedTag[-2..-1]
headCommit = headCommit.substring(1)
} else {
tag = null
headCommit = describedTag[0]
commitsSinceLastTag = 0
}
assert(describedTag.size() > 2)
final def tag = describedTag[0..-3].join('-')
final def commitsSinceLastTag
(commitsSinceLastTag, headCommit) = describedTag[-2..-1]
headCommit = headCommit.substring(1)
return [tag, commitsSinceLastTag, headCommit]
}

Expand Down

0 comments on commit 33b6122

Please sign in to comment.