sync: warn if not tracking a branch

Since tracking a branch prevents repo from updating, make sure we
warn people about the situation when using `repo sync`.

Bug: https://crbug.com/gerrit/11045
Change-Id: I966513f510827cc93194f8df176c6745946bd739
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/258892
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
This commit is contained in:
Mike Frysinger 2020-02-29 02:52:44 -05:00 committed by David Pursehouse
parent bb930461ce
commit 23c900f105

View File

@ -845,6 +845,13 @@ later is required to fix a server side protocol bug.
rp = self.manifest.repoProject rp = self.manifest.repoProject
rp.PreSync() rp.PreSync()
cb = rp.CurrentBranch
if cb:
base = rp.GetBranch(cb).merge
if not base or not base.startswith('refs/heads/'):
print('warning: repo is not tracking a remote branch, so it will not '
'receive updates; run `repo init --repo-branch=stable` to fix.',
file=sys.stderr)
mp = self.manifest.manifestProject mp = self.manifest.manifestProject
mp.PreSync() mp.PreSync()