Fix the initial existence check for "repo"

Commit 27226e742d introduced a warning if
"repo" is not part of the bootstrapped REPO_URL. However, that check was
done too early, directly after the call to _Clone. As the _Clone function
does not actually clone but it only initializes and fetches, the check
needs to be moved to after the call to _Checkout.

To reproduce, call

repo init --no-clone-bundle --repo-branch=master -u https://android.googlesource.com/platform/manifest

which will currently always show the (bogus) warning message. With this
fix, the warning will only be shown if "repo" indeed does not exist.

While at it, also slightly improve the code by using os.path.join().

Change-Id: Ied89e24231addabab6075005065748df1ffa74c4
This commit is contained in:
Sebastian Schuberth 2018-07-13 10:25:52 +02:00
parent b10f0e5b9a
commit 993dcacd17

9
repo
View File

@ -357,16 +357,17 @@ def _Init(args, gitc_init=False):
dst = os.path.abspath(os.path.join(repodir, S_repo))
_Clone(url, dst, opt.quiet, not opt.no_clone_bundle)
if not os.path.isfile('%s/repo' % dst):
_print("warning: '%s' does not look like a git-repo repository, is "
"REPO_URL set correctly?" % url, file=sys.stderr)
if can_verify and not opt.no_repo_verify:
rev = _Verify(dst, branch, opt.quiet)
else:
rev = 'refs/remotes/origin/%s^0' % branch
_Checkout(dst, branch, rev, opt.quiet)
if not os.path.isfile(os.path.join(dst, 'repo')):
_print("warning: '%s' does not look like a git-repo repository, is "
"REPO_URL set correctly?" % url, file=sys.stderr)
except CloneFailure:
if opt.quiet:
_print('fatal: repo init failed; run without --quiet to see why',