From 2f0951b216489ecbd0a28935ca589fb0067a8381 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 10 Jul 2019 17:13:46 -0400 Subject: git_command: set GIT_HTTP_USER_AGENT on all requests We've been setting the User-Agent header when making connections from repo itself, but not when running git (as the latter will set up User-Agent itself). Our Gerrit/Git admins say it'll be helpful if we pass through the repo version settings even when running git. We currently set GIT_HTTP_USER_AGENT and not GIT_USER_AGENT as it's unclear if the extended form works over all protocols. We can wait for a user request. Bug: https://crbug.com/gerrit/11144 Change-Id: I21d293f49534058dbc23225152451df26c5b7bef Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239233 Tested-by: Mike Frysinger Reviewed-by: David Pursehouse --- tests/test_git_command.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/test_git_command.py') diff --git a/tests/test_git_command.py b/tests/test_git_command.py index 5ceb0b33..51171a32 100644 --- a/tests/test_git_command.py +++ b/tests/test_git_command.py @@ -68,3 +68,11 @@ class UserAgentUnitTest(unittest.TestCase): # the general form. m = re.match(r'^git-repo/[^ ]+ ([^ ]+) git/[^ ]+ Python/[0-9.]+', ua) self.assertIsNotNone(m) + + def test_smoke_git(self): + """Make sure git UA returns something useful.""" + ua = git_command.user_agent.git + # We can't dive too deep because of OS/tool differences, but we can check + # the general form. + m = re.match(r'^git/[^ ]+ ([^ ]+) git-repo/[^ ]+', ua) + self.assertIsNotNone(m) -- cgit v1.2.3-54-g00ecf