Commit 6a9ead26 authored by sheyang@google.com's avatar sheyang@google.com

use canonical base URL for projects

BUG=372645
R=iannucci@chromium.org, sergeyberezin@chromium.org

Review URL: https://codereview.chromium.org/271703010

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@270460 0039d316-1c4b-4281-b951-d872f2087c98
parent 174766fb
...@@ -635,12 +635,17 @@ or verify this branch is set up to track another (via the --track argument to ...@@ -635,12 +635,17 @@ or verify this branch is set up to track another (via the --track argument to
return True return True
def GetGitBaseUrlFromConfig(self): def GetGitBaseUrlFromConfig(self):
"""Return the configured base URL from branch.<branchname>.baseurl. """Return the configured base URL from branch.<branchname>.canonical-url.
Returns None if it is not set. Returns None if it is not set.
""" """
return RunGit(['config', 'branch.%s.base-url' % self.GetBranch()], branch = self.GetBranch()
error_ok=True).strip() url = RunGit(['config', 'branch.%s.canonical-url' % branch],
error_ok=True).strip()
if not url:
url = RunGit(['config', 'branch.%s.base-url' % branch],
error_ok=True).strip()
return url
def GetRemoteUrl(self): def GetRemoteUrl(self):
"""Return the configured remote URL, e.g. 'git://example.org/foo.git/'. """Return the configured remote URL, e.g. 'git://example.org/foo.git/'.
...@@ -1074,6 +1079,13 @@ def LoadCodereviewSettingsFromFile(fileobj): ...@@ -1074,6 +1079,13 @@ def LoadCodereviewSettingsFromFile(fileobj):
RunGit(['config', keyvals['PUSH_URL_CONFIG'], RunGit(['config', keyvals['PUSH_URL_CONFIG'],
keyvals['ORIGIN_URL_CONFIG']]) keyvals['ORIGIN_URL_CONFIG']])
if 'CANONICAL_URL' in keyvals:
branchref = RunGit(['symbolic-ref', 'HEAD']).strip()
branch = ShortBranchName(branchref)
RunGit(['config', 'branch.%s.canonical-url' % branch,
keyvals['CANONICAL_URL']],
error_ok=False)
def urlretrieve(source, destination): def urlretrieve(source, destination):
"""urllib is broken for SSL connections via a proxy therefore we """urllib is broken for SSL connections via a proxy therefore we
......
...@@ -204,6 +204,7 @@ class TestGitCl(TestCase): ...@@ -204,6 +204,7 @@ class TestGitCl(TestCase):
return [ return [
((['git', 'config', 'core.editor'],), ''), ((['git', 'config', 'core.editor'],), ''),
] + cc_call + private_call + [ ] + cc_call + private_call + [
((['git', 'config', 'branch.master.canonical-url'],), ''),
((['git', 'config', 'branch.master.base-url'],), ''), ((['git', 'config', 'branch.master.base-url'],), ''),
((['git', ((['git',
'config', '--local', '--get-regexp', '^svn-remote\\.'],), 'config', '--local', '--get-regexp', '^svn-remote\\.'],),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment