refactor(test): explicitly discard errors from git commands in tests
All checks were successful
CI / Test (push) Successful in 38s
CI / Lint (push) Successful in 28s
CI / Build (push) Successful in 22s
Release / Create Release (push) Successful in 38s

This change adds `_ =` assignments to exec.Command(...).Run() calls in test setup code to explicitly ignore error returns, likely to satisfy linters or static analysis tools without changing behavior.
This commit is contained in:
Greg Gauthier 2026-03-31 22:51:58 +01:00
parent 5c9689e4da
commit 7a16b2bcd2
2 changed files with 26 additions and 26 deletions

View File

@ -132,9 +132,9 @@ func TestLatestTagMultiple(t *testing.T) {
if err := os.WriteFile("second.txt", []byte("second"), 0644); err != nil { if err := os.WriteFile("second.txt", []byte("second"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "second commit").Run() _ = exec.Command("git", "commit", "-m", "second commit").Run()
exec.Command("git", "tag", "v0.2.0").Run() _ = exec.Command("git", "tag", "v0.2.0").Run()
tag, err := LatestTag() tag, err := LatestTag()
if err != nil { if err != nil {
@ -157,9 +157,9 @@ func TestPreviousTag(t *testing.T) {
if err := os.WriteFile("second.txt", []byte("second"), 0644); err != nil { if err := os.WriteFile("second.txt", []byte("second"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "second commit").Run() _ = exec.Command("git", "commit", "-m", "second commit").Run()
exec.Command("git", "tag", "v0.2.0").Run() _ = exec.Command("git", "tag", "v0.2.0").Run()
prev, err := PreviousTag("v0.2.0") prev, err := PreviousTag("v0.2.0")
if err != nil { if err != nil {
@ -182,8 +182,8 @@ func TestLogSince(t *testing.T) {
if err := os.WriteFile("new.txt", []byte("new"), 0644); err != nil { if err := os.WriteFile("new.txt", []byte("new"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "feat: add new feature").Run() _ = exec.Command("git", "commit", "-m", "feat: add new feature").Run()
log, err := LogSince("v0.1.0") log, err := LogSince("v0.1.0")
if err != nil { if err != nil {

View File

@ -253,8 +253,8 @@ func TestCreateGitBranchNew(t *testing.T) {
if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil { if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "initial").Run() _ = exec.Command("git", "commit", "-m", "initial").Run()
if err := createGitBranch("feature/test-branch"); err != nil { if err := createGitBranch("feature/test-branch"); err != nil {
t.Fatalf("createGitBranch failed: %v", err) t.Fatalf("createGitBranch failed: %v", err)
@ -283,10 +283,10 @@ func TestCreateGitBranchExisting(t *testing.T) {
if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil { if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "initial").Run() _ = exec.Command("git", "commit", "-m", "initial").Run()
exec.Command("git", "checkout", "-b", "fix/existing").Run() _ = exec.Command("git", "checkout", "-b", "fix/existing").Run()
exec.Command("git", "checkout", "-").Run() // back to main/master _ = exec.Command("git", "checkout", "-").Run() // back to main/master
// Should checkout existing branch, not error // Should checkout existing branch, not error
if err := createGitBranch("fix/existing"); err != nil { if err := createGitBranch("fix/existing"); err != nil {
@ -312,8 +312,8 @@ func TestCommitChangesInGitRepo(t *testing.T) {
if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil { if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "initial").Run() _ = exec.Command("git", "commit", "-m", "initial").Run()
// Create a todo file to commit // Create a todo file to commit
if err := os.MkdirAll("todo/doing", 0755); err != nil { if err := os.MkdirAll("todo/doing", 0755); err != nil {
@ -349,8 +349,8 @@ func TestCommitChangesNothingToCommit(t *testing.T) {
if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil { if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "initial").Run() _ = exec.Command("git", "commit", "-m", "initial").Run()
// Create empty todo dir but no files to stage // Create empty todo dir but no files to stage
if err := os.MkdirAll("todo", 0755); err != nil { if err := os.MkdirAll("todo", 0755); err != nil {
@ -376,8 +376,8 @@ func TestCompleteItemWithGit(t *testing.T) {
if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil { if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "initial").Run() _ = exec.Command("git", "commit", "-m", "initial").Run()
// Set up todo structure // Set up todo structure
for _, d := range []string{"todo/doing", "todo/completed"} { for _, d := range []string{"todo/doing", "todo/completed"} {
@ -389,8 +389,8 @@ func TestCompleteItemWithGit(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// Stage and commit the doing file first so git tracks it // Stage and commit the doing file first so git tracks it
exec.Command("git", "add", "todo/").Run() _ = exec.Command("git", "add", "todo/").Run()
exec.Command("git", "commit", "-m", "add doing item").Run() _ = exec.Command("git", "commit", "-m", "add doing item").Run()
// Now complete as a fix (no README update) // Now complete as a fix (no README update)
if err := completeItem("my-fix", true); err != nil { if err := completeItem("my-fix", true); err != nil {
@ -424,8 +424,8 @@ func TestCompleteItemNonFixUpdatesReadme(t *testing.T) {
if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil { if err := os.WriteFile("init.txt", []byte("init"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", ".").Run() _ = exec.Command("git", "add", ".").Run()
exec.Command("git", "commit", "-m", "initial").Run() _ = exec.Command("git", "commit", "-m", "initial").Run()
// Set up todo structure with README // Set up todo structure with README
for _, d := range []string{"todo/doing", "todo/completed"} { for _, d := range []string{"todo/doing", "todo/completed"} {
@ -440,8 +440,8 @@ func TestCompleteItemNonFixUpdatesReadme(t *testing.T) {
if err := os.WriteFile("todo/doing/my-todo.md", []byte("# My Todo\n"), 0644); err != nil { if err := os.WriteFile("todo/doing/my-todo.md", []byte("# My Todo\n"), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
exec.Command("git", "add", "todo/").Run() _ = exec.Command("git", "add", "todo/").Run()
exec.Command("git", "commit", "-m", "add todo item").Run() _ = exec.Command("git", "commit", "-m", "add todo item").Run()
// Complete as a non-fix (should update README) // Complete as a non-fix (should update README)
if err := completeItem("my-todo", false); err != nil { if err := completeItem("my-todo", false); err != nil {