mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-15 19:22:26 +08:00
fix: commitTime
This commit is contained in:
parent
30a3e6402e
commit
770c6c9326
|
@ -13,28 +13,28 @@ fun String.runCommand(currentWorkingDir: File = file("./")): String {
|
|||
|
||||
data class GitInfo(
|
||||
val commitId: String,
|
||||
val commitTime: Long,
|
||||
val commitTime: String,
|
||||
val tagName: String?,
|
||||
)
|
||||
|
||||
val gitInfo = try {
|
||||
GitInfo(
|
||||
commitId = "git rev-parse HEAD".runCommand(),
|
||||
commitTime = "git log -1 --format=%ct".runCommand().toLong() * 1000L,
|
||||
commitTime = "git log -1 --format=%ct".runCommand(),
|
||||
tagName = try {
|
||||
"git describe --tags --exact-match".runCommand()
|
||||
} catch (e: Exception) {
|
||||
} catch (_: Exception) {
|
||||
println("app: current git commit is not a tag")
|
||||
null
|
||||
},
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
} catch (_: Exception) {
|
||||
println("app: git is not available")
|
||||
null
|
||||
}
|
||||
|
||||
val commitTime = gitInfo?.commitTime ?: 0
|
||||
val commitId = gitInfo?.commitId ?: "unknown"
|
||||
println("app: $gitInfo")
|
||||
|
||||
val vnSuffix = "-${gitInfo?.commitId?.substring(0, 7) ?: "unknown"}"
|
||||
|
||||
plugins {
|
||||
|
@ -71,8 +71,8 @@ android {
|
|||
abiFilters += listOf("arm64-v8a", "x86_64")
|
||||
}
|
||||
|
||||
manifestPlaceholders["commitId"] = commitId
|
||||
manifestPlaceholders["commitTime"] = commitTime
|
||||
manifestPlaceholders["commitId"] = gitInfo?.commitId ?: "unknown"
|
||||
manifestPlaceholders["commitTime"] = gitInfo?.commitTime?.let { it + "000" } ?: "0"
|
||||
}
|
||||
|
||||
lint {}
|
||||
|
|
|
@ -41,25 +41,27 @@ private lateinit var innerApp: Application
|
|||
val app: Application
|
||||
get() = innerApp
|
||||
|
||||
val applicationInfo by lazy {
|
||||
private val applicationInfo by lazy {
|
||||
app.packageManager.getApplicationInfo(
|
||||
app.packageName,
|
||||
PackageManager.GET_META_DATA
|
||||
)
|
||||
}
|
||||
|
||||
data object META {
|
||||
val channel by lazy { applicationInfo.metaData.getString("channel")!! }
|
||||
val commitId by lazy { applicationInfo.metaData.getString("commitId")!! }
|
||||
val commitUrl by lazy { "https://github.com/gkd-kit/gkd/commit/$commitId" }
|
||||
val commitTime by lazy { applicationInfo.metaData.getLong("commitTime") }
|
||||
val updateEnabled by lazy { applicationInfo.metaData.getBoolean("updateEnabled") }
|
||||
val debuggable by lazy { applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0 }
|
||||
val versionCode by lazy { selfAppInfo.versionCode.toInt() }
|
||||
val versionName by lazy { selfAppInfo.versionName!! }
|
||||
val appId by lazy { app.packageName!! }
|
||||
val appName by lazy { app.getString(SafeR.app_name) }
|
||||
}
|
||||
data class AppMeta(
|
||||
val channel: String = applicationInfo.metaData.getString("channel")!!,
|
||||
val commitId: String = applicationInfo.metaData.getString("commitId")!!,
|
||||
val commitUrl: String = "https://github.com/gkd-kit/gkd/commit/${commitId}",
|
||||
val commitTime: Long = applicationInfo.metaData.getString("commitTime")!!.toLong(),
|
||||
val updateEnabled: Boolean = applicationInfo.metaData.getBoolean("updateEnabled"),
|
||||
val debuggable: Boolean = applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0,
|
||||
val versionCode: Int = selfAppInfo.versionCode.toInt(),
|
||||
val versionName: String = selfAppInfo.versionName!!,
|
||||
val appId: String = app.packageName!!,
|
||||
val appName: String = app.getString(SafeR.app_name)
|
||||
)
|
||||
|
||||
val META by lazy { AppMeta() }
|
||||
|
||||
class App : Application() {
|
||||
override fun attachBaseContext(base: Context?) {
|
||||
|
@ -90,7 +92,8 @@ class App : Application() {
|
|||
isLog2FileSwitch = true
|
||||
}
|
||||
LogUtils.d(
|
||||
"META", META
|
||||
"META",
|
||||
META,
|
||||
)
|
||||
initFolder()
|
||||
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
|
||||
|
|
Loading…
Reference in New Issue
Block a user