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: Gavin Mak <gavinmak@google.com>
changes/08/3274108/2
Josip Sokcevic 4 years ago committed by LUCI CQ
parent 2df844314c
commit c08f84e782

@ -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',

Loading…
Cancel
Save