Convert branch revision to remote branch in status call.

We pull the revision from the DEPS url, but if the revision is a branch,  the string must be converted into the local branch names we have for remote branches.

Bug: 1464985
Change-Id: I32c89c947319a04421c46d09d057e42043594e76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4699021
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Auto-Submit: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
changes/21/4699021/5
Joanna Wang 2 years ago committed by LUCI CQ
parent d6b52e67c9
commit a654ff36bb

@ -1044,6 +1044,8 @@ class GitWrapper(SCMWrapper):
if self.url:
_, base_rev = gclient_utils.SplitUrlRevision(self.url)
if base_rev:
if base_rev.startswith('refs/'):
base_rev = ''.join(scm.GIT.RefToRemoteRef(base_rev, self.remote))
merge_base = [base_rev]
self._Run(
['-c', 'core.quotePath=false', 'diff', '--name-status'] + merge_base,

@ -325,6 +325,24 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
'a7142dc9f0009350b96a11f372b6ea658592aa95')
sys.stdout.close()
def testStatusRef(self):
if not self.enabled:
return
options = self.Options()
file_paths = [join(self.base_path, 'a')]
with open(file_paths[0], 'a') as f:
f.writelines('touched\n')
scm = gclient_scm.GitWrapper(self.url + '@refs/heads/feature',
self.root_dir, self.relpath)
file_paths.append(join(self.base_path, 'c')) # feature branch touches c
file_list = []
scm.status(options, self.args, file_list)
self.assertEqual(file_list, file_paths)
self.checkstdout(
('\n________ running \'git -c core.quotePath=false diff --name-status '
'refs/remotes/origin/feature\' in \'%s\'\n\nM\ta\n') %
join(self.root_dir, '.'))
def testStatusNew(self):
if not self.enabled:
return

Loading…
Cancel
Save