Centralize Git identity environment construction
This commit is contained in:
+2
-12
@@ -366,12 +366,7 @@ func CommitAll(dir, message, name, email string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
env := []string{
|
||||
"GIT_AUTHOR_NAME=" + name,
|
||||
"GIT_AUTHOR_EMAIL=" + email,
|
||||
"GIT_COMMITTER_NAME=" + name,
|
||||
"GIT_COMMITTER_EMAIL=" + email,
|
||||
}
|
||||
env := IdentityEnv(name, email)
|
||||
_, err = runEnv(dir, env, "add", "--all")
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -384,12 +379,7 @@ func CommitAll(dir, message, name, email string) (string, error) {
|
||||
}
|
||||
|
||||
func Merge(dir, rev, message, name, email string) error {
|
||||
env := []string{
|
||||
"GIT_AUTHOR_NAME=" + name,
|
||||
"GIT_AUTHOR_EMAIL=" + email,
|
||||
"GIT_COMMITTER_NAME=" + name,
|
||||
"GIT_COMMITTER_EMAIL=" + email,
|
||||
}
|
||||
env := IdentityEnv(name, email)
|
||||
_, err := runEnv(dir, env, "merge", "--no-ff", "--quiet", "--message", message, rev)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package git
|
||||
|
||||
func IdentityEnv(name, email string) []string {
|
||||
return []string{
|
||||
"GIT_AUTHOR_NAME=" + name,
|
||||
"GIT_AUTHOR_EMAIL=" + email,
|
||||
"GIT_COMMITTER_NAME=" + name,
|
||||
"GIT_COMMITTER_EMAIL=" + email,
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func RewriteNotes(repo string, rewrite func(string) string) error {
|
||||
return err
|
||||
}
|
||||
name, email, _ := strings.Cut(who, "\n")
|
||||
env := []string{"GIT_AUTHOR_NAME=" + name, "GIT_AUTHOR_EMAIL=" + email, "GIT_COMMITTER_NAME=" + name, "GIT_COMMITTER_EMAIL=" + email}
|
||||
env := IdentityEnv(name, email)
|
||||
commit, err := runEnv(repo, env, "commit-tree", "-p", parent, "-m", "Rewrite byre ids in notes", tree)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user