From 38bc4c0e294817a70b61e7b545cdcaab5737eebd Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 30 Mar 2015 12:56:00 -0400 Subject: [PATCH] 5416: Improve variable names & filenames. Report original error if git fails with nothing on stderr. --- .../arv-git-httpd/{basic_go13.go => basic_auth_go13.go} | 6 +++--- .../arv-git-httpd/{basic_go14.go => basic_auth_go14.go} | 0 .../arv-git-httpd/{basic_test.go => basic_auth_test.go} | 0 services/arv-git-httpd/server_test.go | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) rename services/arv-git-httpd/{basic_go13.go => basic_auth_go13.go} (69%) rename services/arv-git-httpd/{basic_go14.go => basic_auth_go14.go} (100%) rename services/arv-git-httpd/{basic_test.go => basic_auth_test.go} (100%) diff --git a/services/arv-git-httpd/basic_go13.go b/services/arv-git-httpd/basic_auth_go13.go similarity index 69% rename from services/arv-git-httpd/basic_go13.go rename to services/arv-git-httpd/basic_auth_go13.go index 2839b16f08..087f2c8911 100644 --- a/services/arv-git-httpd/basic_go13.go +++ b/services/arv-git-httpd/basic_auth_go13.go @@ -9,12 +9,12 @@ import ( ) func BasicAuth(r *http.Request) (username, password string, ok bool) { - toks := strings.SplitN(r.Header.Get("Authorization"), " ", 2) - if len(toks) != 2 || toks[0] != "Basic" { + tokens := strings.SplitN(r.Header.Get("Authorization"), " ", 2) + if len(tokens) != 2 || tokens[0] != "Basic" { return "", "", false } - decoded, err := base64.StdEncoding.DecodeString(toks[1]) + decoded, err := base64.StdEncoding.DecodeString(tokens[1]) if err != nil { return "", "", false } diff --git a/services/arv-git-httpd/basic_go14.go b/services/arv-git-httpd/basic_auth_go14.go similarity index 100% rename from services/arv-git-httpd/basic_go14.go rename to services/arv-git-httpd/basic_auth_go14.go diff --git a/services/arv-git-httpd/basic_test.go b/services/arv-git-httpd/basic_auth_test.go similarity index 100% rename from services/arv-git-httpd/basic_test.go rename to services/arv-git-httpd/basic_auth_test.go diff --git a/services/arv-git-httpd/server_test.go b/services/arv-git-httpd/server_test.go index 40f0128174..751e7e41c4 100644 --- a/services/arv-git-httpd/server_test.go +++ b/services/arv-git-httpd/server_test.go @@ -145,8 +145,11 @@ func (s *IntegrationSuite) runGit(c *check.C, gitCmd, repo string, args ...strin go w.Close() output, err := cmd.CombinedOutput() c.Log("git ", gitargs, " => ", err) - if err != nil { - // Easier to match error strings without newlines. + if err != nil && len(output) > 0 { + // If messages appeared on stderr, they are more + // helpful than the err returned by CombinedOutput(). + // + // Easier to match error strings without newlines: err = errors.New(strings.Replace(string(output), "\n", " // ", -1)) } return err -- 2.30.2