From 33b41435dd88f58f5bc115f19e84936fef405b91 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Sat, 2 May 2015 02:16:19 -0400 Subject: [PATCH] 5893: Use git credential helpers for arv-git-httpd tests. Fix workbench helper. 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 | 2 +- services/arv-git-httpd/server_test.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/workbench/app/models/repository.rb b/apps/workbench/app/models/repository.rb index b9b9ce3359..6aa6bb718e 100644 --- a/apps/workbench/app/models/repository.rb +++ b/apps/workbench/app/models/repository.rb @@ -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'], diff --git a/services/arv-git-httpd/server_test.go b/services/arv-git-httpd/server_test.go index 5bf861b7c3..e5ddc29dec 100644 --- a/services/arv-git-httpd/server_test.go +++ b/services/arv-git-httpd/server_test.go @@ -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() -- 2.30.2