move git config from Dockerfile to agent.go Init() method
Move git configuration (user.email, user.name, http.postBuffer) from
Dockerfile creation to runtime initialization in agent.go Init() method.
I want to make the layering for Docker images as simple as possible.
The git configuration here can be harmlessly done once sketch starts,
since it's a vew simple git operations.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s04b2af644e2dbe4fk
diff --git a/loop/agent.go b/loop/agent.go
index 9fb53e5..f01e601 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -1094,6 +1094,28 @@
if !ini.NoGit {
// Capture the original origin before we potentially replace it below
a.gitOrigin = getGitOrigin(ctx, a.workingDir)
+
+ // Configure git user settings
+ if a.config.GitEmail != "" {
+ cmd := exec.CommandContext(ctx, "git", "config", "--global", "user.email", a.config.GitEmail)
+ cmd.Dir = a.workingDir
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("git config --global user.email: %s: %v", out, err)
+ }
+ }
+ if a.config.GitUsername != "" {
+ cmd := exec.CommandContext(ctx, "git", "config", "--global", "user.name", a.config.GitUsername)
+ cmd.Dir = a.workingDir
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("git config --global user.name: %s: %v", out, err)
+ }
+ }
+ // Configure git http.postBuffer
+ cmd := exec.CommandContext(ctx, "git", "config", "--global", "http.postBuffer", "524288000")
+ cmd.Dir = a.workingDir
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("git config --global http.postBuffer: %s: %v", out, err)
+ }
}
// If a remote git addr was specified, we configure the origin remote