Kaynağa Gözat

Fix the initial existence check for "repo"

Commit 27226e742d7e1a3d371531c19a3fdd91a4f9ab4a 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
Sebastian Schuberth 7 yıl önce
ebeveyn
işleme
993dcacd17
1 değiştirilmiş dosya ile 5 ekleme ve 4 silme
  1. 5 4
      repo

+ 5 - 4
repo

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