@@ -6,11 +6,23 @@ import (
66 "path/filepath"
77 "strings"
88 "testing"
9+
10+ "github.com/satococoa/wtp/v2/internal/testutil"
911)
1012
1113func setupTestRepo (t * testing.T ) string {
1214 tempDir := t .TempDir ()
1315
16+ runGitCommand := func (dir string , args ... string ) {
17+ t .Helper ()
18+
19+ cmd := exec .Command ("git" , args ... )
20+ cmd .Dir = dir
21+ if err := cmd .Run (); err != nil {
22+ t .Fatalf ("Failed to run git %v: %v" , args , err )
23+ }
24+ }
25+
1426 // Initialize git repository
1527 cmd := exec .Command ("git" , "init" )
1628 cmd .Dir = tempDir
@@ -23,24 +35,7 @@ func setupTestRepo(t *testing.T) string {
2335 cmd .Dir = tempDir
2436 _ = cmd .Run () // Ignore error if git version is too old
2537
26- // Configure git user
27- cmd = exec .Command ("git" , "config" , "user.name" , "Test User" )
28- cmd .Dir = tempDir
29- if err := cmd .Run (); err != nil {
30- t .Fatalf ("Failed to configure git user: %v" , err )
31- }
32-
33- cmd = exec .
Command (
"git" ,
"config" ,
"user.email" ,
"[email protected] " )
34- cmd .Dir = tempDir
35- if err := cmd .Run (); err != nil {
36- t .Fatalf ("Failed to configure git email: %v" , err )
37- }
38-
39- cmd = exec .Command ("git" , "config" , "commit.gpgsign" , "false" )
40- cmd .Dir = tempDir
41- if err := cmd .Run (); err != nil {
42- t .Fatalf ("Failed to disable gpgsign: %v" , err )
43- }
38+ testutil .ConfigureTestRepo (t , tempDir , runGitCommand )
4439
4540 // Create initial commit
4641 readmeFile := filepath .Join (tempDir , "README.md" )
0 commit comments