-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
67 lines (52 loc) · 1.54 KB
/
Copy pathbuild.gradle
File metadata and controls
67 lines (52 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
plugins {
id "com.palantir.git-version" version "5.0.0"
id "org.sonarqube" version "7.3.1.8318"
}
def gitOutput(String... args) {
return providers.exec {
commandLine(['git'] + args.toList())
ignoreExitValue = true
}.standardOutput.asText.get().trim()
}
def normalizeReleaseTag(String tag) {
if (!tag) {
return null
}
return tag.startsWith('v') ? tag.substring(1) : tag
}
def pep440VersionFromLatestTag() {
def exactTag = gitOutput('describe', '--tags', '--exact-match')
if (exactTag) {
return normalizeReleaseTag(exactTag)
}
def tag = gitOutput('describe', '--tags', '--abbrev=0')
if (!tag) {
tag = '0.0.0'
}
def baseVersion = normalizeReleaseTag(tag)
def distanceText = tag == '0.0.0'
? gitOutput('rev-list', 'HEAD', '--count')
: gitOutput('rev-list', "${tag}..HEAD", '--count')
def distance = distanceText?.isInteger() ? distanceText.toInteger() : 0
def hash = gitOutput('rev-parse', '--short=7', 'HEAD')
def dirty = gitOutput('status', '--porcelain') ? true : false
if (distance == 0 && !dirty) {
return baseVersion
}
def version = "${baseVersion}.post${distance}"
def localParts = []
if (hash) {
localParts.add("g${hash}")
}
if (dirty) {
localParts.add("dirty")
}
if (!localParts.isEmpty()) {
version += "+" + localParts.join(".")
}
return version
}
allprojects {
group = 'mil.army.wmist.regi-python'
version = pep440VersionFromLatestTag()
}