From fb6cb8d3fb3e18e200b284f5fc274f7644c12743 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Mon, 10 Jul 2023 20:10:54 +0800 Subject: [PATCH] Generate repo name at build time --- app/build.gradle.kts | 11 +++++++++++ .../com/hippo/ehviewer/ui/settings/AboutScreen.kt | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7aa4a784f..a72e2a92b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -61,6 +61,16 @@ android { formatter.format(Instant.now()) } + val repoName by lazy { + val stdout = ByteArrayOutputStream() + exec { + commandLine = "git remote get-url origin".split(' ') + standardOutput = stdout + } + stdout.toString().trim().removePrefix("https://github.com/").removePrefix("git@github.com:") + .removeSuffix(".git") + } + defaultConfig { applicationId = "moe.tarsin.ehviewer" minSdk = 28 @@ -85,6 +95,7 @@ android { ) buildConfigField("String", "COMMIT_SHA", "\"$commitSha\"") buildConfigField("String", "BUILD_TIME", "\"$buildTime\"") + buildConfigField("String", "REPO_NAME", "\"$repoName\"") } externalNativeBuild { diff --git a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt index df9dbfffe..5e8ccae47 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt @@ -54,9 +54,10 @@ import tachiyomi.data.release.GithubWorkflowRuns import java.io.File import java.util.zip.ZipInputStream -private const val REPO_URL = "https://github.com/Ehviewer-Overhauled/Ehviewer" -private const val API_URL = "https://api.github.com/repos/Ehviewer-Overhauled/Ehviewer" -private const val RELEASE_URL = "https://github.com/Ehviewer-Overhauled/Ehviewer/releases" +private const val REPO_NAME = BuildConfig.REPO_NAME +private const val REPO_URL = "https://github.com/$REPO_NAME" +private const val API_URL = "https://api.github.com/repos/$REPO_NAME" +private const val RELEASE_URL = "$REPO_URL/releases" @Composable @Stable