From 5461d5ceeb936e5d6d7c0c050c3806da248ff8e1 Mon Sep 17 00:00:00 2001 From: Patel230 Date: Tue, 9 Jun 2026 18:41:17 +0530 Subject: [PATCH] Harden git-backed tests and align 0.1.0 sums --- go.sum | 3 ++- go.work.sum | 10 ++++----- internal/engine/git/git_context_test.go | 10 +++++++++ .../intelligence/repomap/changeset_test.go | 8 +++++++ .../intelligence/repomap/file_grouper_test.go | 8 +++++++ .../intelligence/repomap/ownership_test.go | 8 +++++++ internal/multiagent/parallel/parallel_test.go | 22 +++++++++++++++++++ .../parallel/worktree_manager_test.go | 22 +++++++++++++++++++ internal/snapshot/snapshot.go | 6 +++++ internal/snapshot/snapshot_test.go | 10 +++++++++ internal/snapshot/workspace_test.go | 16 ++++++++++++++ 11 files changed, 117 insertions(+), 6 deletions(-) diff --git a/go.sum b/go.sum index 0094bcba..171b99d9 100644 --- a/go.sum +++ b/go.sum @@ -11,7 +11,8 @@ github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2 github.com/GrayCodeAI/eyrie v0.1.0 h1:Vh5LPhsiyiBctQBylHLOnIJNYkFrqd1618QcUydHvLU= github.com/GrayCodeAI/inspect v0.1.0 h1:cYURqxVMD0hJp42NVzxFWiarYxVtmYNCB+Rg9aoblfE= github.com/GrayCodeAI/sight v0.1.0 h1:p0NQyAA/pwo3b1Eye6UxjVw2x3H+gPPzmBava6H3Wrs= -github.com/GrayCodeAI/tok v0.1.0 h1:rzM6QpOKs2+lnCUGi4Ra6wpRljGtCzlrY5H1JW+I13U= +github.com/GrayCodeAI/tok v0.1.0 h1:6lhxIGg1eDsnOtAuGOZf803aqj4CrPmVmTwKRw25Zio= +github.com/GrayCodeAI/tok v0.1.0/go.mod h1:oqA7HXbXuyrZ3+uJC+TKJWmYYPlyShaXGDQpftEJ9OE= github.com/GrayCodeAI/trace v0.1.0 h1:favfKoX8pLV/TSs8EMnaFe4hLepR6djX9ByIqY6YtM8= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= diff --git a/go.work.sum b/go.work.sum index 85b0f7d3..00cf473b 100644 --- a/go.work.sum +++ b/go.work.sum @@ -51,13 +51,13 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0/go.mod h1:P4WPRUkOhJC13W//jWpyfJNDAIpvRbAUIYLX/4jtlE0= github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.53.0/go.mod h1:ZPpqegjbE99EPKsu3iUWV22A04wzGPcAY/ziSIQEEgs= github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0/go.mod h1:cSgYe11MCNYunTnRXrKiR/tHc0eoKjICUuWpNZoVCOo= -github.com/GrayCodeAI/eyrie v0.1.0/go.mod h1:Iznws0IS267Cp9Zb5VsjCaHLewJEGR61Bv9F3hwJujY= +github.com/GrayCodeAI/eyrie v0.1.0/go.mod h1:g/hyB7+YCSYSkw5zJfZrWxLJyCoy2psR8QOsXN4ZzsI= github.com/GrayCodeAI/hawk v0.1.0/go.mod h1:JIiKVFiFJL52OKNW/ndHRtjzVbVy6CX3HBydPpDHkwA= -github.com/GrayCodeAI/inspect v0.1.0/go.mod h1:IOH0pwvJ5TmNFSRDkLH3nbWbawE/PPaZojV2Lj5BSnU= -github.com/GrayCodeAI/sight v0.1.0/go.mod h1:Nmq6CEf3fXhrrJzPhGRRldEnKtqWHvuWMG+OHjRv2wo= -github.com/GrayCodeAI/tok v0.1.0/go.mod h1:JLV+xe2sbHfQjqX66u4tOMTNXqHW0OhkMQqY8wIm1aI= +github.com/GrayCodeAI/inspect v0.1.0/go.mod h1:DDhIU8Ikg2kjIXsiBupbTbLhmf4Jn8Ut7SV70spF0Qs= +github.com/GrayCodeAI/sight v0.1.0/go.mod h1:hcEdCWt07/igu5HeCxB052OkQ5WOQ/f/WkEO1z1fcOM= +github.com/GrayCodeAI/tok v0.1.0/go.mod h1:oqA7HXbXuyrZ3+uJC+TKJWmYYPlyShaXGDQpftEJ9OE= github.com/GrayCodeAI/trace v0.1.0/go.mod h1:sPBHmg0kctNnRJ/bRIq9rmPFKje31BEnWdBbrNc4tRM= -github.com/GrayCodeAI/yaad v0.1.0/go.mod h1:uKu+u22cVALLopdMBIzt0a4VMiPx+WOdjqkgtoUbzjY= +github.com/GrayCodeAI/yaad v0.1.0/go.mod h1:fwJ+AwEqvnoGiDA51iQ1NO696xI9j7WkkYg4UuwrmQM= github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE= github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= diff --git a/internal/engine/git/git_context_test.go b/internal/engine/git/git_context_test.go index 577e1ab6..d82842cf 100644 --- a/internal/engine/git/git_context_test.go +++ b/internal/engine/git/git_context_test.go @@ -29,6 +29,11 @@ func setupTestRepo(t *testing.T) (string, func()) { "GIT_AUTHOR_EMAIL=alice@example.com", "GIT_COMMITTER_NAME=Alice", "GIT_COMMITTER_EMAIL=alice@example.com", + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", ) out, err := cmd.CombinedOutput() if err != nil { @@ -46,6 +51,11 @@ func setupTestRepo(t *testing.T) (string, func()) { "GIT_AUTHOR_EMAIL="+email, "GIT_COMMITTER_NAME="+author, "GIT_COMMITTER_EMAIL="+email, + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", ) out, err := cmd.CombinedOutput() if err != nil { diff --git a/internal/intelligence/repomap/changeset_test.go b/internal/intelligence/repomap/changeset_test.go index 06021420..d613ef6b 100644 --- a/internal/intelligence/repomap/changeset_test.go +++ b/internal/intelligence/repomap/changeset_test.go @@ -85,6 +85,14 @@ func runGit(t *testing.T, dir string, args ...string) { t.Helper() cmd := exec.CommandContext(context.Background(), "git", args...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("git %v failed: %v\n%s", args, err, out) diff --git a/internal/intelligence/repomap/file_grouper_test.go b/internal/intelligence/repomap/file_grouper_test.go index 5eaaf4df..512b4a0d 100644 --- a/internal/intelligence/repomap/file_grouper_test.go +++ b/internal/intelligence/repomap/file_grouper_test.go @@ -551,6 +551,14 @@ func runGrouperGit(t *testing.T, dir string, args ...string) { t.Helper() cmd := exec.CommandContext(context.Background(), "git", args...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("git %v failed: %v\n%s", args, err, out) diff --git a/internal/intelligence/repomap/ownership_test.go b/internal/intelligence/repomap/ownership_test.go index 9549ff73..dac3e9d0 100644 --- a/internal/intelligence/repomap/ownership_test.go +++ b/internal/intelligence/repomap/ownership_test.go @@ -463,6 +463,14 @@ type gitTestCmd struct { func (g *gitTestCmd) CombinedOutput() ([]byte, error) { cmd := exec.CommandContext(context.Background(), "git", g.args...) cmd.Dir = g.dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) return cmd.CombinedOutput() } diff --git a/internal/multiagent/parallel/parallel_test.go b/internal/multiagent/parallel/parallel_test.go index 99d0081d..832bf114 100644 --- a/internal/multiagent/parallel/parallel_test.go +++ b/internal/multiagent/parallel/parallel_test.go @@ -26,6 +26,14 @@ func initTestRepo(t *testing.T) string { t.Helper() cmd := exec.CommandContext(context.Background(), args[0], args[1:]...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("command %v failed: %s: %v", args, out, err) @@ -35,6 +43,8 @@ func initTestRepo(t *testing.T) string { run("git", "init", "-b", "main") run("git", "config", "user.email", "test@hawk.dev") run("git", "config", "user.name", "Hawk Test") + run("git", "config", "commit.gpgsign", "false") + run("git", "config", "tag.gpgsign", "false") // Create an initial commit so branches can be made. readme := filepath.Join(dir, "README.md") @@ -335,6 +345,18 @@ func TestMergeWorktree(t *testing.T) { t.Helper() cmd := exec.CommandContext(context.Background(), "git", args...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_AUTHOR_NAME=Hawk Test", + "GIT_AUTHOR_EMAIL=test@hawk.dev", + "GIT_COMMITTER_NAME=Hawk Test", + "GIT_COMMITTER_EMAIL=test@hawk.dev", + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("git %v in %s: %s: %v", args, dir, out, err) diff --git a/internal/multiagent/parallel/worktree_manager_test.go b/internal/multiagent/parallel/worktree_manager_test.go index 82e4a042..83e65cf5 100644 --- a/internal/multiagent/parallel/worktree_manager_test.go +++ b/internal/multiagent/parallel/worktree_manager_test.go @@ -23,6 +23,14 @@ func initManagerTestRepo(t *testing.T) string { t.Helper() cmd := exec.CommandContext(context.Background(), args[0], args[1:]...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("command %v failed: %s: %v", args, out, err) @@ -32,6 +40,8 @@ func initManagerTestRepo(t *testing.T) string { run("git", "init", "-b", "main") run("git", "config", "user.email", "test@hawk.dev") run("git", "config", "user.name", "Hawk Test") + run("git", "config", "commit.gpgsign", "false") + run("git", "config", "tag.gpgsign", "false") readme := filepath.Join(dir, "README.md") if err := os.WriteFile(readme, []byte("# worktree manager test\n"), 0o644); err != nil { @@ -545,6 +555,18 @@ func runGitIn(t *testing.T, dir string, args ...string) { t.Helper() cmd := exec.CommandContext(context.Background(), "git", args...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_AUTHOR_NAME=Hawk Test", + "GIT_AUTHOR_EMAIL=test@hawk.dev", + "GIT_COMMITTER_NAME=Hawk Test", + "GIT_COMMITTER_EMAIL=test@hawk.dev", + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("git %v in %s: %s: %v", args, dir, out, err) diff --git a/internal/snapshot/snapshot.go b/internal/snapshot/snapshot.go index f7cc4f46..8332f0b4 100644 --- a/internal/snapshot/snapshot.go +++ b/internal/snapshot/snapshot.go @@ -67,6 +67,12 @@ func (t *Tracker) Init() error { if err := t.gitWork("config", "user.name", "hawk-snapshot"); err != nil { return fmt.Errorf("config name: %w", err) } + if err := t.gitWork("config", "commit.gpgsign", "false"); err != nil { + return fmt.Errorf("config commit signing: %w", err) + } + if err := t.gitWork("config", "tag.gpgsign", "false"); err != nil { + return fmt.Errorf("config tag signing: %w", err) + } return nil } diff --git a/internal/snapshot/snapshot_test.go b/internal/snapshot/snapshot_test.go index 21658594..879a0903 100644 --- a/internal/snapshot/snapshot_test.go +++ b/internal/snapshot/snapshot_test.go @@ -14,6 +14,8 @@ func setupTestProject(t *testing.T) string { run(t, dir, "git", "init") run(t, dir, "git", "config", "user.email", "test@test.com") run(t, dir, "git", "config", "user.name", "Test") + run(t, dir, "git", "config", "commit.gpgsign", "false") + run(t, dir, "git", "config", "tag.gpgsign", "false") os.WriteFile(filepath.Join(dir, "main.go"), []byte("package main\n"), 0o644) run(t, dir, "git", "add", ".") run(t, dir, "git", "commit", "-m", "initial") @@ -24,6 +26,14 @@ func run(t *testing.T, dir, name string, args ...string) { t.Helper() cmd := exec.CommandContext(context.Background(), name, args...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) if out, err := cmd.CombinedOutput(); err != nil { t.Fatalf("%s %v failed: %s: %v", name, args, out, err) } diff --git a/internal/snapshot/workspace_test.go b/internal/snapshot/workspace_test.go index 3575cbe1..cb498fe8 100644 --- a/internal/snapshot/workspace_test.go +++ b/internal/snapshot/workspace_test.go @@ -20,6 +20,8 @@ func setupWorkspaceProject(t *testing.T) string { runCmd(t, dir, "git", "init") runCmd(t, dir, "git", "config", "user.email", "test@test.com") runCmd(t, dir, "git", "config", "user.name", "Test") + runCmd(t, dir, "git", "config", "commit.gpgsign", "false") + runCmd(t, dir, "git", "config", "tag.gpgsign", "false") // Create project files os.MkdirAll(filepath.Join(dir, "pkg"), 0o755) @@ -37,6 +39,14 @@ func runCmd(t *testing.T, dir, name string, args ...string) { t.Helper() cmd := exec.CommandContext(context.Background(), name, args...) cmd.Dir = dir + cmd.Env = append( + os.Environ(), + "GIT_CONFIG_COUNT=2", + "GIT_CONFIG_KEY_0=commit.gpgsign", + "GIT_CONFIG_VALUE_0=false", + "GIT_CONFIG_KEY_1=tag.gpgsign", + "GIT_CONFIG_VALUE_1=false", + ) if out, err := cmd.CombinedOutput(); err != nil { t.Fatalf("%s %v failed: %s: %v", name, args, out, err) } @@ -365,6 +375,8 @@ func TestEmptyProject(t *testing.T) { runCmd(t, dir, "git", "init") runCmd(t, dir, "git", "config", "user.email", "test@test.com") runCmd(t, dir, "git", "config", "user.name", "Test") + runCmd(t, dir, "git", "config", "commit.gpgsign", "false") + runCmd(t, dir, "git", "config", "tag.gpgsign", "false") storeDir := filepath.Join(t.TempDir(), "snapshots") store := NewSnapshotStore(storeDir) @@ -387,6 +399,8 @@ func TestLargeFile_Handling(t *testing.T) { runCmd(t, dir, "git", "init") runCmd(t, dir, "git", "config", "user.email", "test@test.com") runCmd(t, dir, "git", "config", "user.name", "Test") + runCmd(t, dir, "git", "config", "commit.gpgsign", "false") + runCmd(t, dir, "git", "config", "tag.gpgsign", "false") // Create a 1MB file largeContent := make([]byte, 1024*1024) @@ -600,6 +614,8 @@ func TestCapture_FileMode(t *testing.T) { runCmd(t, dir, "git", "init") runCmd(t, dir, "git", "config", "user.email", "test@test.com") runCmd(t, dir, "git", "config", "user.name", "Test") + runCmd(t, dir, "git", "config", "commit.gpgsign", "false") + runCmd(t, dir, "git", "config", "tag.gpgsign", "false") // Create file with specific mode os.WriteFile(filepath.Join(dir, "script.sh"), []byte("#!/bin/bash\necho hello\n"), 0o755)