summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py49
1 files changed, 1 insertions, 48 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index c5bf2823..b73de71c 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -32,7 +32,7 @@ else:
32from color import Coloring 32from color import Coloring
33from command import InteractiveCommand, MirrorSafeCommand 33from command import InteractiveCommand, MirrorSafeCommand
34from error import ManifestParseError 34from error import ManifestParseError
35from project import SyncBuffer, MetaProject 35from project import SyncBuffer
36from git_config import GitConfig 36from git_config import GitConfig
37from git_command import git_require, MIN_GIT_VERSION 37from git_command import git_require, MIN_GIT_VERSION
38 38
@@ -374,52 +374,6 @@ to update the working directory files.
374 print(' rm -r %s/.repo' % self.manifest.topdir) 374 print(' rm -r %s/.repo' % self.manifest.topdir)
375 print('and try again.') 375 print('and try again.')
376 376
377 def _SyncProjectHooks(self, opt, repodir):
378 """Downloads the defined hooks supplied in the projecthooks element
379
380 """
381 # Always delete projecthooks and re-download for every new init.
382 projecthooksdir = os.path.join(repodir, 'projecthooks')
383 if os.path.exists(projecthooksdir):
384 shutil.rmtree(projecthooksdir)
385 for remotename in self.manifest.remotes:
386 r = self.manifest.remotes.get(remotename)
387 if r.projecthookName is not None and r.projecthookRevision is not None:
388 projecthookurl = r.resolvedFetchUrl.rstrip('/') + '/' + r.projecthookName
389
390 ph = MetaProject(manifest = self.manifest,
391 name = r.projecthookName,
392 gitdir = os.path.join(projecthooksdir,'%s/%s.git' % (remotename, r.projecthookName)),
393 worktree = os.path.join(projecthooksdir,'%s/%s' % (remotename, r.projecthookName)))
394
395 ph.revisionExpr = r.projecthookRevision
396 is_new = not ph.Exists
397
398 if is_new:
399 if not opt.quiet:
400 print('Get projecthook %s' % \
401 GitConfig.ForUser().UrlInsteadOf(projecthookurl), file=sys.stderr)
402 ph._InitGitDir(MirrorOverride=True)
403
404 phr = ph.GetRemote(remotename)
405 phr.name = 'origin'
406 phr.url = projecthookurl
407 phr.ResetFetch()
408 phr.Save()
409
410 if not ph.Sync_NetworkHalf(quiet=opt.quiet, is_new=is_new, clone_bundle=False):
411 print('fatal: cannot obtain projecthook %s' % phr.url, file=sys.stderr)
412
413 # Better delete the git dir if we created it; otherwise next
414 # time (when user fixes problems) we won't go through the "is_new" logic.
415 if is_new:
416 shutil.rmtree(ph.gitdir)
417 sys.exit(1)
418
419 syncbuf = SyncBuffer(ph.config)
420 ph.Sync_LocalHalf(syncbuf)
421 syncbuf.Finish()
422
423 def Execute(self, opt, args): 377 def Execute(self, opt, args):
424 git_require(MIN_GIT_VERSION, fail=True) 378 git_require(MIN_GIT_VERSION, fail=True)
425 379
@@ -435,7 +389,6 @@ to update the working directory files.
435 389
436 self._SyncManifest(opt) 390 self._SyncManifest(opt)
437 self._LinkManifest(opt.manifest_name) 391 self._LinkManifest(opt.manifest_name)
438 self._SyncProjectHooks(opt, self.manifest.repodir)
439 392
440 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: 393 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
441 if opt.config_name or self._ShouldConfigureUser(): 394 if opt.config_name or self._ShouldConfigureUser():