diff options
author | Jonathan Nieder <jrn@google.com> | 2015-03-17 11:29:58 -0700 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2015-03-17 11:29:58 -0700 |
commit | 9371979628a945a1caf526aeff84a1ac68a22efe (patch) | |
tree | dddfeb5a602f799f31a8d62ac5feb72fa2fb06ab /subcmds/init.py | |
parent | 20860042617d43ed192d60659cd92c71ea251519 (diff) | |
download | git-repo-9371979628a945a1caf526aeff84a1ac68a22efe.tar.gz |
Revert "Implementation of manifest defined githooks"v1.12.20
This reverts commit 38e4387f8eb8cffd6359d726c38a7c524fef07e3.
A "repo init" followed by "repo sync" is meant to be as safe as
"git clone". In particular it should not run arbitrary code provided
by the manifest owner.
It would still be nice to have support for manifest-defined git hooks
--- they'd just need a prompt like the upload RepoHook has. Hopefully
a later change can bring them back.
Change-Id: I5ecd90fb5c2ed64f103d856d1ffcba38a47b062d
Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r-- | subcmds/init.py | 49 |
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: | |||
32 | from color import Coloring | 32 | from color import Coloring |
33 | from command import InteractiveCommand, MirrorSafeCommand | 33 | from command import InteractiveCommand, MirrorSafeCommand |
34 | from error import ManifestParseError | 34 | from error import ManifestParseError |
35 | from project import SyncBuffer, MetaProject | 35 | from project import SyncBuffer |
36 | from git_config import GitConfig | 36 | from git_config import GitConfig |
37 | from git_command import git_require, MIN_GIT_VERSION | 37 | from 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(): |