From 9d340fc2d1d30a86ac697a7506107e3e92c052a4 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Tue, 3 Sep 2024 02:04:09 +0300 Subject: [PATCH] fix: git dubious ownership error --- entrypoint.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/entrypoint.go b/entrypoint.go index 0530084..bdc3aff 100644 --- a/entrypoint.go +++ b/entrypoint.go @@ -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 buildOptions := []string{"build", "-v", "-x", "-buildmode", "exe", "-ldflags", ldflags, "-o", buildFilePath, packagePath}