Commit c08f84e7 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Update git fetch refspecs on git migrate

User may have set fetch only on the old default branch. This ensures
that fetch works with new default branch.

R=gavinmak@google.com

Bug: 1268775
Change-Id: I971cdd041e8e8a7f06a20f4de348c1395c7b6e06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3274108
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
parent 2df84431
......@@ -54,6 +54,12 @@ def main():
if project_head != 'refs/heads/main':
raise RuntimeError("The repository is not migrated yet.")
# User may have set to fetch only old default branch. Ensure fetch is tracking
# main too.
git_common.run('config', '--unset-all',
'remote.origin.fetch', 'refs/heads/*')
git_common.run('config', '--add',
'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*')
logging.info("Running fetch...")
git_common.run('fetch', remote)
logging.info("Updating remote HEAD...")
......
......@@ -57,6 +57,8 @@ class CMDFormatTestCase(unittest.TestCase):
return
elif args[0] == 'branch':
return
elif args[0] == 'config':
return
raise Exception('Did not expect such run git command: %s' % args[0])
mock_runs = mock.patch('git_migrate_default_branch.git_common.run',
......
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