@@ -69,9 +69,21 @@ func initializeTestGitRepo(name string) (*testGitRepo, error) {
69
69
repo .Files = append (repo .Files , tmpfn )
70
70
initCmd := exec .Command ("git" , "init" )
71
71
initCmd .Dir = dir
72
- if out , err := initCmd .Output (); err != nil {
72
+ if out , err := initCmd .CombinedOutput (); err != nil {
73
73
return repo , fmt .Errorf ("unable to initialize repository: %q" , out )
74
74
}
75
+
76
+ configEmailCmd := exec .
Command (
"git" ,
"config" ,
"user.email" ,
"[email protected] " )
77
+ configEmailCmd .Dir = dir
78
+ if out , err := configEmailCmd .CombinedOutput (); err != nil {
79
+ return repo , fmt .Errorf ("unable to set git email prefs: %q" , out )
80
+ }
81
+ configNameCmd := exec .Command ("git" , "config" , "user.name" , "Me Myself" )
82
+ configNameCmd .Dir = dir
83
+ if out , err := configNameCmd .CombinedOutput (); err != nil {
84
+ return repo , fmt .Errorf ("unable to set git name prefs: %q" , out )
85
+ }
86
+
75
87
return repo , nil
76
88
}
77
89
@@ -85,7 +97,7 @@ func (r *testGitRepo) addSubmodule() error {
85
97
}
86
98
subCmd := exec .Command ("git" , "submodule" , "add" , "file://" + subRepo .Path , "sub" )
87
99
subCmd .Dir = r .Path
88
- if out , err := subCmd .Output (); err != nil {
100
+ if out , err := subCmd .CombinedOutput (); err != nil {
89
101
return fmt .Errorf ("unable to add submodule: %q" , out )
90
102
}
91
103
r .Submodule = subRepo
@@ -101,7 +113,7 @@ func (r *testGitRepo) getRef(offset int) (string, error) {
101
113
}
102
114
refCmd := exec .Command ("git" , "rev-parse" , "HEAD" + q )
103
115
refCmd .Dir = r .Path
104
- if out , err := refCmd .Output (); err != nil {
116
+ if out , err := refCmd .CombinedOutput (); err != nil {
105
117
return "" , fmt .Errorf ("unable to checkout %d offset: %q" , offset , out )
106
118
} else {
107
119
return strings .TrimSpace (string (out )), nil
@@ -111,7 +123,7 @@ func (r *testGitRepo) getRef(offset int) (string, error) {
111
123
func (r * testGitRepo ) createBranch (name string ) error {
112
124
refCmd := exec .Command ("git" , "checkout" , "-b" , name )
113
125
refCmd .Dir = r .Path
114
- if out , err := refCmd .Output (); err != nil {
126
+ if out , err := refCmd .CombinedOutput (); err != nil {
115
127
return fmt .Errorf ("unable to checkout new branch: %q" , out )
116
128
}
117
129
return nil
@@ -120,7 +132,7 @@ func (r *testGitRepo) createBranch(name string) error {
120
132
func (r * testGitRepo ) switchBranch (name string ) error {
121
133
refCmd := exec .Command ("git" , "checkout" , name )
122
134
refCmd .Dir = r .Path
123
- if out , err := refCmd .Output (); err != nil {
135
+ if out , err := refCmd .CombinedOutput (); err != nil {
124
136
return fmt .Errorf ("unable to checkout branch: %q" , out )
125
137
}
126
138
return nil
@@ -143,12 +155,12 @@ func (r *testGitRepo) addCommit() error {
143
155
}
144
156
addCmd := exec .Command ("git" , "add" , "." )
145
157
addCmd .Dir = r .Path
146
- if out , err := addCmd .Output (); err != nil {
158
+ if out , err := addCmd .CombinedOutput (); err != nil {
147
159
return fmt .Errorf ("unable to add files to repo: %q" , out )
148
160
}
149
161
commitCmd := exec .Command ("git" , "commit" , "-a" , "-m" , "test commit" )
150
162
commitCmd .Dir = r .Path
151
- out , err := commitCmd .Output ()
163
+ out , err := commitCmd .CombinedOutput ()
152
164
if err != nil {
153
165
return fmt .Errorf ("unable to commit: %q" , out )
154
166
}
0 commit comments