summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-09-30 22:39:49 -0400
committerMike Frysinger <vapier@google.com>2019-10-01 05:40:28 +0000
commit71b0f312b15b597ab54d4d3bd6629efdcf188884 (patch)
treeb02a38b231c6e7e94776706d08670bc66db14ddf /main.py
parent369814b4a77adcc78b2549ad728e0d69175f08e8 (diff)
downloadgit-repo-71b0f312b15b597ab54d4d3bd6629efdcf188884.tar.gz
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 <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/main.py b/main.py
index 0b19aeb5..515cdf47 100755
--- a/main.py
+++ b/main.py
@@ -46,7 +46,7 @@ except ImportError:
46from color import SetDefaultColoring 46from color import SetDefaultColoring
47import event_log 47import event_log
48from repo_trace import SetTrace 48from repo_trace import SetTrace
49from git_command import git, GitCommand, RepoUserAgent 49from git_command import git, GitCommand, user_agent
50from git_config import init_ssh, close_ssh 50from git_config import init_ssh, close_ssh
51from command import InteractiveCommand 51from command import InteractiveCommand
52from command import MirrorSafeCommand 52from command import MirrorSafeCommand
@@ -297,11 +297,11 @@ def _PruneOptions(argv, opt):
297 297
298class _UserAgentHandler(urllib.request.BaseHandler): 298class _UserAgentHandler(urllib.request.BaseHandler):
299 def http_request(self, req): 299 def http_request(self, req):
300 req.add_header('User-Agent', RepoUserAgent()) 300 req.add_header('User-Agent', user_agent.repo)
301 return req 301 return req
302 302
303 def https_request(self, req): 303 def https_request(self, req):
304 req.add_header('User-Agent', RepoUserAgent()) 304 req.add_header('User-Agent', user_agent.repo)
305 return req 305 return req
306 306
307def _AddPasswordFromUserInput(handler, msg, req): 307def _AddPasswordFromUserInput(handler, msg, req):