Check for commit hash before appending another in build.gradle caclulateVersion (#7537)

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
pull/7547/head
Matilda-Clerke 3 months ago committed by GitHub
parent 8ae0db4b24
commit a8bbcd5d8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      build.gradle

@ -997,9 +997,13 @@ def buildTime() {
@Memoized
def calculateVersion() {
// Regex pattern for basic calendar versioning, with provision to omit patch rev
def calVerPattern = ~/\d+\.\d+(\.\d+)?(-.*)?/
def calVerPattern = ~/\d+\.\d+(\.\d+)?(-\w+)?$/
def calVerWithCommitPattern = ~/\d+\.\d+(\.\d+)?(-\w+)?-[0-9a-fA-F]{7,8}$/
def gitDetails = getGitCommitDetails() // Adjust length as needed
if (project.hasProperty('version') && (project.version =~ calVerPattern)) {
if (project.hasProperty('version') && project.version =~ calVerWithCommitPattern) {
println("Utilising supplied version as it appears to already contain commit hash: ${project.version}")
return project.version
} else if (project.hasProperty('version') && project.version =~ calVerPattern) {
println("Generating project version using supplied version: ${project.version}-${gitDetails.hash}")
return "${project.version}-${gitDetails.hash}"
} else {

Loading…
Cancel
Save