Skip to content

Commit

Permalink
Merge pull request #3133 from Stypox/gradle-app-id-suffix
Browse files Browse the repository at this point in the history
Change app id based on current git branch
  • Loading branch information
TobiGr authored Mar 11, 2020
2 parents 33475ef + 92f4010 commit f7822a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
32 changes: 31 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
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 {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "org.schabi.newpipe"
resValue "string", "app_name", "NewPipe"
minSdkVersion 19
targetSdkVersion 28
versionCode 860
Expand All @@ -28,7 +47,18 @@ android {
debug {
multiDexEnabled true
debuggable true
applicationIdSuffix ".debug"

// suffix the app id and the app name with git branch name
def workingBranch = getGitWorkingBranch()
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"
resValue "string", "app_name", "NewPipe Debug"
} else {
applicationIdSuffix ".debug." + normalizedWorkingBranch
resValue "string", "app_name", "NewPipe " + workingBranch
}
}
}

Expand Down
17 changes: 0 additions & 17 deletions app/src/debug/AndroidManifest.xml

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">NewPipe</string>
<string name="main_bg_subtitle">Tap \"Search\" to get started</string>
<string name="view_count_text">%1$s views</string>
<string name="upload_date_text">Published on %1$s</string>
Expand Down

0 comments on commit f7822a4

Please sign in to comment.