From 71b0f312b15b597ab54d4d3bd6629efdcf188884 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Sep 2019 22:39:49 -0400 Subject: git_command: refactor User-Agent settings Convert the RepoUserAgent function into a UserAgent class. This makes it cleaner to hold internal state, and will make it easier to add a separate git User-Agent, although we don't do it here. We make the RepoSourceVersion independent of GitCommand so that it can be called by the class (later). Bug: https://crbug.com/gerrit/11144 Change-Id: Iab4e1f974b8733a36b243b2d03f5085a96effa19 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239232 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index 0b19aeb5..515cdf47 100755 --- a/main.py +++ b/main.py @@ -46,7 +46,7 @@ except ImportError: from color import SetDefaultColoring import event_log from repo_trace import SetTrace -from git_command import git, GitCommand, RepoUserAgent +from git_command import git, GitCommand, user_agent from git_config import init_ssh, close_ssh from command import InteractiveCommand from command import MirrorSafeCommand @@ -297,11 +297,11 @@ def _PruneOptions(argv, opt): class _UserAgentHandler(urllib.request.BaseHandler): def http_request(self, req): - req.add_header('User-Agent', RepoUserAgent()) + req.add_header('User-Agent', user_agent.repo) return req def https_request(self, req): - req.add_header('User-Agent', RepoUserAgent()) + req.add_header('User-Agent', user_agent.repo) return req def _AddPasswordFromUserInput(handler, msg, req): -- cgit v1.2.3-54-g00ecf