Browse code

Fix git clone tests

Jordan Liggitt authored on 2016/05/28 01:17:23
Showing 1 changed files
... ...
@@ -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", "me@example.com")
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 85
 	}
86 86
 	subCmd := exec.Command("git", "submodule", "add", "file://"+subRepo.Path, "sub")
87 87
 	subCmd.Dir = r.Path
88
-	if out, err := subCmd.Output(); err != nil {
88
+	if out, err := subCmd.CombinedOutput(); err != nil {
89 89
 		return fmt.Errorf("unable to add submodule: %q", out)
90 90
 	}
91 91
 	r.Submodule = subRepo
... ...
@@ -101,7 +113,7 @@ func (r *testGitRepo) getRef(offset int) (string, error) {
101 101
 	}
102 102
 	refCmd := exec.Command("git", "rev-parse", "HEAD"+q)
103 103
 	refCmd.Dir = r.Path
104
-	if out, err := refCmd.Output(); err != nil {
104
+	if out, err := refCmd.CombinedOutput(); err != nil {
105 105
 		return "", fmt.Errorf("unable to checkout %d offset: %q", offset, out)
106 106
 	} else {
107 107
 		return strings.TrimSpace(string(out)), nil
... ...
@@ -111,7 +123,7 @@ func (r *testGitRepo) getRef(offset int) (string, error) {
111 111
 func (r *testGitRepo) createBranch(name string) error {
112 112
 	refCmd := exec.Command("git", "checkout", "-b", name)
113 113
 	refCmd.Dir = r.Path
114
-	if out, err := refCmd.Output(); err != nil {
114
+	if out, err := refCmd.CombinedOutput(); err != nil {
115 115
 		return fmt.Errorf("unable to checkout new branch: %q", out)
116 116
 	}
117 117
 	return nil
... ...
@@ -120,7 +132,7 @@ func (r *testGitRepo) createBranch(name string) error {
120 120
 func (r *testGitRepo) switchBranch(name string) error {
121 121
 	refCmd := exec.Command("git", "checkout", name)
122 122
 	refCmd.Dir = r.Path
123
-	if out, err := refCmd.Output(); err != nil {
123
+	if out, err := refCmd.CombinedOutput(); err != nil {
124 124
 		return fmt.Errorf("unable to checkout branch: %q", out)
125 125
 	}
126 126
 	return nil
... ...
@@ -143,12 +155,12 @@ func (r *testGitRepo) addCommit() error {
143 143
 	}
144 144
 	addCmd := exec.Command("git", "add", ".")
145 145
 	addCmd.Dir = r.Path
146
-	if out, err := addCmd.Output(); err != nil {
146
+	if out, err := addCmd.CombinedOutput(); err != nil {
147 147
 		return fmt.Errorf("unable to add files to repo: %q", out)
148 148
 	}
149 149
 	commitCmd := exec.Command("git", "commit", "-a", "-m", "test commit")
150 150
 	commitCmd.Dir = r.Path
151
-	out, err := commitCmd.Output()
151
+	out, err := commitCmd.CombinedOutput()
152 152
 	if err != nil {
153 153
 		return fmt.Errorf("unable to commit: %q", out)
154 154
 	}