Refresh native Git helper aliases after app upgrade
- Rebuild the app-private git-exec helper directory when the packaged native Git binary changes. - Remove stale helper aliases before recreating symlinks/copies. - Add regression coverage for refreshing cached Git exec aliases across binary changes.
This commit is contained in:
@@ -852,6 +852,7 @@ class GitRepositoryRuntime private constructor(
|
||||
} else {
|
||||
File(binary.parentFile ?: binary.absoluteFile.parentFile ?: sandboxesRoot, "git-exec")
|
||||
}
|
||||
refreshGitExecDirectoryIfNeeded(directory, binary)
|
||||
directory.mkdirs()
|
||||
|
||||
File(directory, "git").also { alias ->
|
||||
@@ -870,7 +871,27 @@ class GitRepositoryRuntime private constructor(
|
||||
return directory
|
||||
}
|
||||
|
||||
private fun refreshGitExecDirectoryIfNeeded(directory: File, binary: File) {
|
||||
val fingerprint = buildString {
|
||||
append(binary.absolutePath)
|
||||
append('\n')
|
||||
append(binary.length())
|
||||
append('\n')
|
||||
append(binary.lastModified())
|
||||
}
|
||||
val stamp = File(directory, ".binary-fingerprint")
|
||||
val previousFingerprint = stamp.takeIf { it.isFile }?.readText()
|
||||
if (previousFingerprint != fingerprint) {
|
||||
directory.deleteRecursively()
|
||||
}
|
||||
directory.mkdirs()
|
||||
stamp.writeText(fingerprint)
|
||||
}
|
||||
|
||||
private fun createGitAlias(binary: File, alias: File) {
|
||||
if (alias.exists() || Files.isSymbolicLink(alias.toPath())) {
|
||||
alias.delete()
|
||||
}
|
||||
if (context != null) {
|
||||
try {
|
||||
Os.symlink(binary.absolutePath, alias.absolutePath)
|
||||
|
||||
Reference in New Issue
Block a user