fix: git dubious ownership error

This commit is contained in:
Chen Asraf 2024-09-03 02:04:09 +03:00 committed by GitHub
parent 10e5fcf82f
commit 9d340fc2d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,6 +78,22 @@ func build(packageName, destDir string, platform map[string]string, ldflags stri
/*------------*/ /*------------*/
// add git owner exception for the build directory
ensureOptions := []string{"config", "--global", "--add", "safe.directory", workspaceDir}
// generate `git config` command
ensureCmd := exec.Command("git", ensureOptions...)
// execute `git config` command
fmt.Println("Adding git directory to whitelist:", ensureCmd.String())
if output, err := ensureCmd.CombinedOutput(); err != nil {
fmt.Println("An error occurred in git:", err)
fmt.Printf("%s\n", output)
os.Exit(1)
} else {
fmt.Printf("%s\n", output)
}
// command-line options for the `go build` command // command-line options for the `go build` command
buildOptions := []string{"build", "-v", "-x", "-buildmode", "exe", "-ldflags", ldflags, "-o", buildFilePath, packagePath} buildOptions := []string{"build", "-v", "-x", "-buildmode", "exe", "-ldflags", ldflags, "-o", buildFilePath, packagePath}