Skip to content

Commit dc90f22

Browse files
author
OpenShift Bot
committed
Merge pull request #9063 from liggitt/git-test
Merged by openshift-bot
2 parents 9089acc + ce0760b commit dc90f22

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

pkg/build/builder/source_test.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,21 @@ func initializeTestGitRepo(name string) (*testGitRepo, error) {
6969
repo.Files = append(repo.Files, tmpfn)
7070
initCmd := exec.Command("git", "init")
7171
initCmd.Dir = dir
72-
if out, err := initCmd.Output(); err != nil {
72+
if out, err := initCmd.CombinedOutput(); err != nil {
7373
return repo, fmt.Errorf("unable to initialize repository: %q", out)
7474
}
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+
7587
return repo, nil
7688
}
7789

@@ -85,7 +97,7 @@ func (r *testGitRepo) addSubmodule() error {
8597
}
8698
subCmd := exec.Command("git", "submodule", "add", "file://"+subRepo.Path, "sub")
8799
subCmd.Dir = r.Path
88-
if out, err := subCmd.Output(); err != nil {
100+
if out, err := subCmd.CombinedOutput(); err != nil {
89101
return fmt.Errorf("unable to add submodule: %q", out)
90102
}
91103
r.Submodule = subRepo
@@ -101,7 +113,7 @@ func (r *testGitRepo) getRef(offset int) (string, error) {
101113
}
102114
refCmd := exec.Command("git", "rev-parse", "HEAD"+q)
103115
refCmd.Dir = r.Path
104-
if out, err := refCmd.Output(); err != nil {
116+
if out, err := refCmd.CombinedOutput(); err != nil {
105117
return "", fmt.Errorf("unable to checkout %d offset: %q", offset, out)
106118
} else {
107119
return strings.TrimSpace(string(out)), nil
@@ -111,7 +123,7 @@ func (r *testGitRepo) getRef(offset int) (string, error) {
111123
func (r *testGitRepo) createBranch(name string) error {
112124
refCmd := exec.Command("git", "checkout", "-b", name)
113125
refCmd.Dir = r.Path
114-
if out, err := refCmd.Output(); err != nil {
126+
if out, err := refCmd.CombinedOutput(); err != nil {
115127
return fmt.Errorf("unable to checkout new branch: %q", out)
116128
}
117129
return nil
@@ -120,7 +132,7 @@ func (r *testGitRepo) createBranch(name string) error {
120132
func (r *testGitRepo) switchBranch(name string) error {
121133
refCmd := exec.Command("git", "checkout", name)
122134
refCmd.Dir = r.Path
123-
if out, err := refCmd.Output(); err != nil {
135+
if out, err := refCmd.CombinedOutput(); err != nil {
124136
return fmt.Errorf("unable to checkout branch: %q", out)
125137
}
126138
return nil
@@ -143,12 +155,12 @@ func (r *testGitRepo) addCommit() error {
143155
}
144156
addCmd := exec.Command("git", "add", ".")
145157
addCmd.Dir = r.Path
146-
if out, err := addCmd.Output(); err != nil {
158+
if out, err := addCmd.CombinedOutput(); err != nil {
147159
return fmt.Errorf("unable to add files to repo: %q", out)
148160
}
149161
commitCmd := exec.Command("git", "commit", "-a", "-m", "test commit")
150162
commitCmd.Dir = r.Path
151-
out, err := commitCmd.Output()
163+
out, err := commitCmd.CombinedOutput()
152164
if err != nil {
153165
return fmt.Errorf("unable to commit: %q", out)
154166
}

0 commit comments

Comments
 (0)