Audit of f8e6783
This commit is contained in:
+8
-13
@@ -237,13 +237,10 @@ func SquashCommit(repo, worktree, target, message string, env []string, sign fun
|
||||
}
|
||||
|
||||
func signCommit(repo, commit string, sign func(payload []byte) ([]byte, error)) (string, error) {
|
||||
payload, stderr, code, err := runCodeInput(context.Background(), repo, nil, nil, "cat-file", "commit", commit)
|
||||
payload, err := runRaw(repo, nil, "", "cat-file", "commit", commit)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if code != 0 {
|
||||
return "", fmt.Errorf("git cat-file commit %s: exit status %d: %s", commit, code, stderr)
|
||||
}
|
||||
sig, err := sign([]byte(payload))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("signing the commit: %w", err)
|
||||
@@ -402,17 +399,15 @@ func run(dir string, args ...string) (string, error) {
|
||||
}
|
||||
|
||||
func runEnv(dir string, env []string, args ...string) (string, error) {
|
||||
out, stderr, code, err := runCode(dir, env, args...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if code != 0 {
|
||||
return "", fmt.Errorf("git %s: exit status %d: %s", strings.Join(args, " "), code, stderr)
|
||||
}
|
||||
return out, nil
|
||||
return runInput(dir, env, "", args...)
|
||||
}
|
||||
|
||||
func runInput(dir string, env []string, input string, args ...string) (string, error) {
|
||||
out, err := runRaw(dir, env, input, args...)
|
||||
return strings.TrimSpace(out), err
|
||||
}
|
||||
|
||||
func runRaw(dir string, env []string, input string, args ...string) (string, error) {
|
||||
out, stderr, code, err := runCodeInput(context.Background(), dir, env, strings.NewReader(input), args...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -420,7 +415,7 @@ func runInput(dir string, env []string, input string, args ...string) (string, e
|
||||
if code != 0 {
|
||||
return "", fmt.Errorf("git %s: exit status %d: %s", strings.Join(args, " "), code, stderr)
|
||||
}
|
||||
return strings.TrimSpace(out), nil
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func runCode(dir string, env []string, args ...string) (string, string, int, error) {
|
||||
|
||||
+1
-13
@@ -2,7 +2,6 @@ package git
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -147,7 +146,7 @@ func RewriteNotes(repo string, rewrite func(string) string) error {
|
||||
}
|
||||
|
||||
func catBlobs(repo string, shas []string) (map[string]string, error) {
|
||||
out, err := runRaw(repo, strings.Join(shas, "\n")+"\n", "cat-file", "--batch")
|
||||
out, err := runRaw(repo, nil, strings.Join(shas, "\n")+"\n", "cat-file", "--batch")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -182,14 +181,3 @@ func splitLines(out string) []string {
|
||||
}
|
||||
return strings.Split(out, "\n")
|
||||
}
|
||||
|
||||
func runRaw(dir, input string, args ...string) (string, error) {
|
||||
out, stderr, code, err := runCodeInput(context.Background(), dir, nil, strings.NewReader(input), args...)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if code != 0 {
|
||||
return "", fmt.Errorf("git %s: exit status %d: %s", strings.Join(args, " "), code, stderr)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user