mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-20 23:00:28 +01:00
Add more checks to prevent build failures in gradle branch suffix
- Add function `getGitWorkingBranch` that returns the current working branch, and "" if it could not be determined (either because git is not installed or because the directory is not a git repo). - Make sure normalizedWorkingBranch is not empty (leading to an invalid app id terminating with `.`) - Make normalizedWorkingBranch lowercase - Add comments
This commit is contained in:
parent
3434ff4d45
commit
92f4010e8e
@ -3,6 +3,24 @@ apply plugin: 'kotlin-android'
|
|||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
|
|
||||||
|
|
||||||
|
static String getGitWorkingBranch() {
|
||||||
|
try {
|
||||||
|
def gitProcess = "git rev-parse --abbrev-ref HEAD".execute()
|
||||||
|
gitProcess.waitFor()
|
||||||
|
if (gitProcess.exitValue() == 0) {
|
||||||
|
return gitProcess.text.trim()
|
||||||
|
} else {
|
||||||
|
// not a git repository
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
// git was not found
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion '28.0.3'
|
buildToolsVersion '28.0.3'
|
||||||
@ -31,12 +49,14 @@ android {
|
|||||||
debuggable true
|
debuggable true
|
||||||
|
|
||||||
// suffix the app id and the app name with git branch name
|
// suffix the app id and the app name with git branch name
|
||||||
def workingBranch = "git rev-parse --abbrev-ref HEAD".execute().text.trim()
|
def workingBranch = getGitWorkingBranch()
|
||||||
if (workingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev") {
|
def normalizedWorkingBranch = workingBranch.replaceAll("[^A-Za-z]+", "").toLowerCase()
|
||||||
|
if (normalizedWorkingBranch.isEmpty() || workingBranch == "master" || workingBranch == "dev") {
|
||||||
|
// default values when branch name could not be determined or is master or dev
|
||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
resValue "string", "app_name", "NewPipe Debug"
|
resValue "string", "app_name", "NewPipe Debug"
|
||||||
} else {
|
} else {
|
||||||
applicationIdSuffix ".debug." + workingBranch.replaceAll("[^A-Za-z]+", "")
|
applicationIdSuffix ".debug." + normalizedWorkingBranch
|
||||||
resValue "string", "app_name", "NewPipe " + workingBranch
|
resValue "string", "app_name", "NewPipe " + workingBranch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user