-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclean_release.gradle
More file actions
29 lines (27 loc) · 981 Bytes
/
clean_release.gradle
File metadata and controls
29 lines (27 loc) · 981 Bytes
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
ext.cleanRelease = {
def clean = true
def applicationId = android.defaultConfig.applicationId
String headCommitMessage = grgit.head().shortMessage
while (headCommitMessage.contains("[gradle-release-task]")) {
clean = false
println "Found git commit: $headCommitMessage"
if (headCommitMessage.indexOf("$applicationId-") > -1) {
def tagName = headCommitMessage.split("$applicationId-")[1]
println "Removing the git tag: $tagName"
try {
grgit.tag.remove {
names = [tagName]
}
} catch (Exception e) {
println "Error while removing git tag:\n $e"
}
}
println "Resetting the git commit permanently!"
grgit.reset(commit: "HEAD~1", mode: "hard")
headCommitMessage = grgit.head().shortMessage
}
if (clean){
println "Repository is already clean"
}
println "Done!"
}