5416: Improve variable names & filenames. Report original error if git fails with...
authorTom Clegg <tom@curoverse.com>
Mon, 30 Mar 2015 16:56:00 +0000 (12:56 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 30 Mar 2015 17:00:35 +0000 (13:00 -0400)
services/arv-git-httpd/basic_auth_go13.go [moved from services/arv-git-httpd/basic_go13.go with 69% similarity]
services/arv-git-httpd/basic_auth_go14.go [moved from services/arv-git-httpd/basic_go14.go with 100% similarity]
services/arv-git-httpd/basic_auth_test.go [moved from services/arv-git-httpd/basic_test.go with 100% similarity]
services/arv-git-httpd/server_test.go

similarity index 69%
rename from services/arv-git-httpd/basic_go13.go
rename to services/arv-git-httpd/basic_auth_go13.go
index 2839b16f083bfe530ab715e201175698c762ccb6..087f2c891166cd52256c77ad1d7d72304f01ddfe 100644 (file)
@@ -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
        }
index 40f0128174cc9fc22c84632666fa70429e1ddf09..751e7e41c484fb659b6d875b75bb62124b4372e4 100644 (file)
@@ -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