Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: git_cl.py

Issue 9969099: Allow overriding base-url in git-cl. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
===================================================================
--- git_cl.py (revision 130362)
+++ git_cl.py (working copy)
@@ -411,7 +411,14 @@
GIT_INSTRUCTIONS_URL)
return self._remote
+ def GetGitBaseUrlFromConfig(self):
+ """Return the configured base URL from branch.<branchname>.baseurl.
+ Returns None if it is not set.
+ """
+ return RunGit(['config', 'branch.%s.base-url' % self.GetBranch()],
+ error_ok=True).strip()
+
def GetRemoteUrl(self):
"""Return the configured remote URL, e.g. 'git://example.org/foo.git/'.
@@ -786,6 +793,19 @@
DownloadHooks(True)
return 0
M-A Ruel 2012/04/03 15:18:40 2 spaces between file level symbols
kalmard 2012/04/03 15:27:10 Done.
+def CMDbaseurl(parser, args):
+ """get or set base-url for this branch"""
+ branchref = RunGit(['symbolic-ref', 'HEAD']).strip()
+ branch = ShortBranchName(branchref)
+ _, args = parser.parse_args(args)
+ if len(args) == 0:
M-A Ruel 2012/04/03 15:18:40 if not args:
kalmard 2012/04/03 15:27:10 Done.
+ print("Current base-url:")
+ return RunGit(['config', 'branch.%s.base-url' % branch],
+ error_ok=False).strip()
+ else:
+ print("Setting base-url to %s" % args[0])
+ return RunGit(['config', 'branch.%s.base-url' % branch, args[0]],
+ error_ok=False).strip()
M-A Ruel 2012/04/03 15:18:40 same
kalmard 2012/04/03 15:27:10 Done.
def CMDstatus(parser, args):
"""show status of changelists"""
@@ -982,18 +1002,19 @@
# Include the upstream repo's URL in the change -- this is useful for
# projects that have their source spread across multiple repos.
- remote_url = None
- if settings.GetIsGitSvn():
- # URL is dependent on the current directory.
- data = RunGit(['svn', 'info'], cwd=settings.GetRoot())
- if data:
- keys = dict(line.split(': ', 1) for line in data.splitlines()
- if ': ' in line)
- remote_url = keys.get('URL', None)
- else:
- if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch():
- remote_url = (cl.GetRemoteUrl() + '@'
- + cl.GetUpstreamBranch().split('/')[-1])
+ remote_url = cl.GetGitBaseUrlFromConfig()
+ if not remote_url:
+ if settings.GetIsGitSvn():
+ # URL is dependent on the current directory.
+ data = RunGit(['svn', 'info'], cwd=settings.GetRoot())
+ if data:
+ keys = dict(line.split(': ', 1) for line in data.splitlines()
+ if ': ' in line)
+ remote_url = keys.get('URL', None)
+ else:
+ if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch():
+ remote_url = (cl.GetRemoteUrl() + '@'
+ + cl.GetUpstreamBranch().split('/')[-1])
if remote_url:
upload_args.extend(['--base_url', remote_url])
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698