From 81dcf6378d81abf6556ee90005b67fb2dd747e2d Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Dec 2013 10:43:49 -0800 Subject: [PATCH] Make `repository pull` install hooks the first time Summary: Ref T4257. Currently, the pull logic looks like this: if (new) { create(); } else { if (hosted) { install_hooks(); } else { update(); } } This means that the first time you run `repository pull`, hooks aren't installed, which makes debugging trickier. Instead, reorganize the logic: if (new) { create(); } else { if (!hosted) { update(); } } if (hosted) { install_hooks(); } Test Plan: Ran `bin/repository pull` on a new `hg` repo and got hooks installed immediately. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4257 Differential Revision: https://secure.phabricator.com/D7818 --- .../PhabricatorRepositoryPullEngine.php | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php index b92696fde2..60d264b472 100644 --- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php @@ -82,32 +82,29 @@ final class PhabricatorRepositoryPullEngine $this->executeSubversionCreate(); } } else { - if ($repository->isHosted()) { - if ($is_git) { - $this->installGitHook(); - } else if ($is_svn) { - $this->installSubversionHook(); - } else if ($is_hg) { - $this->installMercurialHook(); - } else { - $this->logPull( - pht( - "Repository '%s' is hosted, so Phabricator does not pull ". - "updates for it.", - $callsign)); - } - } else { + if (!$repository->isHosted()) { $this->logPull( pht( "Updating the working copy for repository '%s'.", $callsign)); if ($is_git) { $this->executeGitUpdate(); - } else { + } else if ($is_hg) { $this->executeMercurialUpdate(); } } } + + if ($repository->isHosted()) { + if ($is_git) { + $this->installGitHook(); + } else if ($is_svn) { + $this->installSubversionHook(); + } else if ($is_hg) { + $this->installMercurialHook(); + } + } + } catch (Exception $ex) { $this->abortPull( pht('Pull of "%s" failed: %s', $callsign, $ex->getMessage()),