Simplify codebase per audit of 8b89f14

This commit is contained in:
Ian Gulliver
2026-10-23 15:10:06 -07:00
parent a53b293528
commit b5a72d713b
14 changed files with 361 additions and 820 deletions
+11 -11
View File
@@ -53,7 +53,7 @@ func Inspect(ctx context.Context, path string) (RepoInfo, error) {
return RepoInfo{}, err
}
remote, _, code, err := runCode(ctx, root, nil, "remote", "get-url", Remote)
remote, _, code, err := runCode(ctx, root, "remote", "get-url", Remote)
if err != nil {
return RepoInfo{}, err
}
@@ -65,7 +65,7 @@ func Inspect(ctx context.Context, path string) (RepoInfo, error) {
}
func HasRemote(ctx context.Context, repo string) (bool, error) {
_, _, code, err := runCode(ctx, repo, nil, "remote", "get-url", Remote)
_, _, code, err := runCode(ctx, repo, "remote", "get-url", Remote)
return err == nil && code == 0, err
}
@@ -92,7 +92,7 @@ func AddWorktree(ctx context.Context, repo, path, branch, base string) (string,
}
func EnsureBranchCommit(ctx context.Context, repo, branch string, env []string) error {
_, _, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch+"^{commit}")
_, _, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch+"^{commit}")
if err != nil || code == 0 {
return err
}
@@ -152,7 +152,7 @@ func RemoveWorktree(ctx context.Context, repo, path, branch string) error {
}
}
_, _, code, err := runCode(ctx, repo, nil, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch)
_, _, code, err := runCode(ctx, repo, "rev-parse", "--verify", "--quiet", "refs/heads/"+branch)
if err != nil || code != 0 {
return err
}
@@ -206,7 +206,7 @@ func SquashCommit(ctx context.Context, repo, worktree, target, message string, e
return "", err
}
out, stderr, code, err := runCode(ctx, repo, nil, "merge-tree", "--write-tree", "--name-only", "--merge-base="+base, head, tree)
out, stderr, code, err := runCode(ctx, repo, "merge-tree", "--write-tree", "--name-only", "--merge-base="+base, head, tree)
if err != nil {
return "", err
}
@@ -237,7 +237,7 @@ func SquashCommit(ctx context.Context, repo, worktree, target, message string, e
if err != nil {
return "", err
}
signing, stderr, code, err := runCode(ctx, repo, nil, "config", "--type=bool", "--get", "commit.gpgsign")
signing, stderr, code, err := runCode(ctx, repo, "config", "--type=bool", "--get", "commit.gpgsign")
if err != nil {
return "", err
}
@@ -340,7 +340,7 @@ func BranchHead(ctx context.Context, repo, branch string) (string, error) {
}
func IsAncestor(ctx context.Context, dir, ancestor, descendant string) (bool, error) {
_, stderr, code, err := runCode(ctx, dir, nil, "merge-base", "--is-ancestor", ancestor, descendant)
_, stderr, code, err := runCode(ctx, dir, "merge-base", "--is-ancestor", ancestor, descendant)
if err != nil {
return false, err
}
@@ -354,7 +354,7 @@ func IsAncestor(ctx context.Context, dir, ancestor, descendant string) (bool, er
}
func MergeInProgress(ctx context.Context, dir string) (bool, error) {
_, _, code, err := runCode(ctx, dir, nil, "rev-parse", "--quiet", "--verify", "MERGE_HEAD")
_, _, code, err := runCode(ctx, dir, "rev-parse", "--quiet", "--verify", "MERGE_HEAD")
return err == nil && code == 0, err
}
@@ -368,7 +368,7 @@ func AbortMerge(ctx context.Context, dir string) error {
}
func ReadFile(ctx context.Context, repo, rev, path string) (string, bool, error) {
_, _, code, err := runCode(ctx, repo, nil, "cat-file", "-e", rev+":"+path)
_, _, code, err := runCode(ctx, repo, "cat-file", "-e", rev+":"+path)
if err != nil {
return "", false, err
}
@@ -434,8 +434,8 @@ func runRaw(ctx context.Context, dir string, env []string, input string, args ..
return out, nil
}
func runCode(ctx context.Context, dir string, env []string, args ...string) (string, string, int, error) {
out, stderr, code, err := runCodeInput(context.WithoutCancel(ctx), dir, env, nil, args...)
func runCode(ctx context.Context, dir string, args ...string) (string, string, int, error) {
out, stderr, code, err := runCodeInput(context.WithoutCancel(ctx), dir, nil, nil, args...)
return strings.TrimSpace(out), stderr, code, err
}