Browse code

Added Git logging to build output

oatmealraisin authored on 2016/08/18 01:01:10
Showing 2 changed files
... ...
@@ -199,7 +199,7 @@ func extractGitSource(gitClient GitClient, gitSource *api.GitBuildSource, revisi
199 199
 		return false, nil
200 200
 	}
201 201
 
202
-	glog.V(0).Infof("Downloading %q ...", gitSource.URI)
202
+	glog.V(0).Infof("Cloning %q ...", gitSource.URI)
203 203
 
204 204
 	// Check source URI, trying to connect to the server only if not using a proxy.
205 205
 	if err := checkSourceURI(gitClient, gitSource.URI, timeout); err != nil {
... ...
@@ -209,9 +209,6 @@ func extractGitSource(gitClient GitClient, gitSource *api.GitBuildSource, revisi
209 209
 	// check if we specify a commit, ref, or branch to check out
210 210
 	usingRef := len(gitSource.Ref) != 0 || (revision != nil && revision.Git != nil && len(revision.Git.Commit) != 0)
211 211
 
212
-	// Recursive clone if we're not going to checkout a ref and submodule update later
213
-	glog.V(3).Infof("Cloning source from %s", gitSource.URI)
214
-
215 212
 	// Only use the quiet flag if Verbosity is not 5 or greater
216 213
 	quiet := !glog.Is(5)
217 214
 	if err := gitClient.CloneWithOptions(dir, gitSource.URI, git.CloneOptions{Recursive: !usingRef, Quiet: quiet, Shallow: !usingRef}); err != nil {
... ...
@@ -236,6 +233,14 @@ func extractGitSource(gitClient GitClient, gitSource *api.GitBuildSource, revisi
236 236
 		}
237 237
 	}
238 238
 
239
+	if glog.Is(0) {
240
+		if information, gitErr := gitClient.GetInfo(dir); gitErr == nil {
241
+			glog.Infof("\tCommit:\t%s (%s)\n", information.CommitID, information.Message)
242
+			glog.Infof("\tAuthor:\t%s <%s>\n", information.AuthorName, information.AuthorEmail)
243
+			glog.Infof("\tDate:\t%s\n", information.Date)
244
+		}
245
+	}
246
+
239 247
 	return true, nil
240 248
 }
241 249
 
... ...
@@ -147,6 +147,13 @@ os::cmd::expect_success "oc delete all --all"
147 147
 os::cmd::expect_success "docker rmi -f ${docker_registry}/image-ns/busybox:latest"
148 148
 os::test::junit::declare_suite_end
149 149
 
150
+# Test to see that we're reporting the correct commit being used by the build
151
+os::test::junit::declare_suite_start "extended/cmd/new-build"
152
+os::cmd::expect_success "oc new-build https://github.com/openshift/ruby-hello-world.git#bd94cbb228465d30d9d3430e80b503757a2a1d97"
153
+os::cmd::try_until_text "oc logs builds/ruby-hello-world-1" "Commit:[[:space:]]*bd94cbb228465d30d9d3430e80b503757a2a1d97"
154
+os::cmd::expect_success "oc delete all --all"
155
+os::test::junit::declare_suite_end
156
+
150 157
 os::test::junit::declare_suite_start "extended/cmd/service-signer"
151 158
 # check to make sure that service serving cert signing works correctly
152 159
 # nginx currently needs to run as root