5893: Use git credential helpers for arv-git-httpd tests. Fix workbench helper.
authorTom Clegg <tom@curoverse.com>
Sat, 2 May 2015 06:16:19 +0000 (02:16 -0400)
committerTom Clegg <tom@curoverse.com>
Sat, 2 May 2015 06:41:41 +0000 (02:41 -0400)
The sporadic "git exited 128" errors -- very common in git2 and rare
in git1 -- seem to have been caused by git getting SIGPIPE when the
credential helper exited without consuming stdin. The solution is for
the credential helper to discard its standard input before exiting.

apps/workbench/app/models/repository.rb
services/arv-git-httpd/server_test.go

index b9b9ce3359dcaa148432446b438aba50edbbadf5..6aa6bb718ee0d27f0f367d29863691fef5c35df3 100644 (file)
@@ -96,7 +96,7 @@ class Repository < ArvadosBase
       "credential.#{http_fetch_url}.username", 'none'],
      ['git', '--git-dir', @workdir, 'config', '--local',
       "credential.#{http_fetch_url}.helper",
-      '!token(){ echo password="$ARVADOS_API_TOKEN"; }; token'],
+      '!cred(){ cat >/dev/null; if [ "$1" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred'],
      ['git', '--git-dir', @workdir, 'config', '--local',
            'http.sslVerify',
            Rails.configuration.arvados_insecure_https ? 'false' : 'true'],
index 5bf861b7c39a87430c00862300d2cd59722f1a34..e5ddc29dec93b2a9a2f08fef9d7f31b9706da2dc 100644 (file)
@@ -91,6 +91,17 @@ func (s *IntegrationSuite) SetUpTest(c *check.C) {
        _, err = exec.Command("sh", "-c", "cd "+s.tmpWorkdir+" && echo work >work && git add work && git -c user.name=Foo -c user.email=Foo commit -am 'workdir: test'").CombinedOutput()
        c.Assert(err, check.Equals, nil)
 
+       _, err = exec.Command("git", "config",
+               "--file", s.tmpWorkdir+"/.git/config",
+               "credential.http://"+s.testServer.Addr+"/.helper",
+               "!cred(){ cat >/dev/null; if [ \"$1\" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred").Output()
+       c.Assert(err, check.Equals, nil)
+       _, err = exec.Command("git", "config",
+               "--file", s.tmpWorkdir+"/.git/config",
+               "credential.http://"+s.testServer.Addr+"/.username",
+               "none").Output()
+       c.Assert(err, check.Equals, nil)
+
        theConfig = &config{
                Addr:       ":",
                GitCommand: "/usr/bin/git",
@@ -127,9 +138,10 @@ func (s *IntegrationSuite) runGit(c *check.C, token, gitCmd, repo string, args .
        os.Chdir(s.tmpWorkdir)
 
        gitargs := append([]string{
-               gitCmd, "http://none:" + token + "@" + s.testServer.Addr + "/" + repo,
+               gitCmd, "http://" + s.testServer.Addr + "/" + repo,
        }, args...)
        cmd := exec.Command("git", gitargs...)
+       cmd.Env = append(os.Environ(), "ARVADOS_API_TOKEN="+token)
        w, err := cmd.StdinPipe()
        c.Assert(err, check.Equals, nil)
        w.Close()