Differential D7682 Diff 17351 src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | try { | ||||
| $this->executeGitCreate(); | $this->executeGitCreate(); | ||||
| } else if ($is_hg) { | } else if ($is_hg) { | ||||
| $this->executeMercurialCreate(); | $this->executeMercurialCreate(); | ||||
| } else { | } else { | ||||
| $this->executeSubversionCreate(); | $this->executeSubversionCreate(); | ||||
| } | } | ||||
| } else { | } else { | ||||
| if ($repository->isHosted()) { | if ($repository->isHosted()) { | ||||
| if ($is_git) { | |||||
| $this->installGitHook(); | |||||
| } else { | |||||
| $this->logPull( | $this->logPull( | ||||
| pht( | pht( | ||||
| "Repository '%s' is hosted, so Phabricator does not pull ". | "Repository '%s' is hosted, so Phabricator does not pull ". | ||||
| "updates for it.", | "updates for it.", | ||||
| $callsign)); | $callsign)); | ||||
| } | |||||
| } else { | } else { | ||||
| $this->logPull( | $this->logPull( | ||||
| pht( | pht( | ||||
| "Updating the working copy for repository '%s'.", | "Updating the working copy for repository '%s'.", | ||||
| $callsign)); | $callsign)); | ||||
| if ($is_git) { | if ($is_git) { | ||||
| $this->executeGitUpdate(); | $this->executeGitUpdate(); | ||||
| } else { | } else { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | private function updateRepositoryInitStatus($code, $message = null) { | ||||
| $this->getRepository()->writeStatusMessage( | $this->getRepository()->writeStatusMessage( | ||||
| PhabricatorRepositoryStatusMessage::TYPE_INIT, | PhabricatorRepositoryStatusMessage::TYPE_INIT, | ||||
| $code, | $code, | ||||
| array( | array( | ||||
| 'message' => $message | 'message' => $message | ||||
| )); | )); | ||||
| } | } | ||||
| private function installHook($path) { | |||||
| $this->log('%s', pht('Installing commit hook to "%s"...', $path)); | |||||
| $repository = $this->getRepository(); | |||||
| $callsign = $repository->getCallsign(); | |||||
| $root = dirname(phutil_get_library_root('phabricator')); | |||||
| $bin = $root.'/bin/commit-hook'; | |||||
| $cmd = csprintf('exec -- %s %s', $bin, $callsign); | |||||
| $hook = "#!/bin/sh\n{$cmd}\n"; | |||||
| Filesystem::writeFile($path, $hook); | |||||
| Filesystem::changePermissions($path, 0755); | |||||
| } | |||||
| /* -( Pulling Git Working Copies )----------------------------------------- */ | /* -( Pulling Git Working Copies )----------------------------------------- */ | ||||
| /** | /** | ||||
| * @task git | * @task git | ||||
| */ | */ | ||||
| private function executeGitCreate() { | private function executeGitCreate() { | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | do { | ||||
| "stderr:{$stderr}\n"); | "stderr:{$stderr}\n"); | ||||
| } else { | } else { | ||||
| $retry = false; | $retry = false; | ||||
| } | } | ||||
| } while ($retry); | } while ($retry); | ||||
| } | } | ||||
| /** | |||||
| * @task git | |||||
| */ | |||||
| private function installGitHook() { | |||||
| $repository = $this->getRepository(); | |||||
| $path = $repository->getLocalPath(); | |||||
| if ($repository->isWorkingCopyBare()) { | |||||
| $path .= 'hooks/pre-receive'; | |||||
btrahan: are we implicitly in the.git folder in this case or? | |||||
Not Done Inline ActionsYeah, in the bare case the top level folder is basically the same as ".git/". epriestley: Yeah, in the bare case the top level folder is basically the same as ".git/". | |||||
| } else { | |||||
| $path .= '.git/hooks/pre-receive'; | |||||
| } | |||||
| $this->installHook($path); | |||||
| } | |||||
| /* -( Pulling Mercurial Working Copies )----------------------------------- */ | /* -( Pulling Mercurial Working Copies )----------------------------------- */ | ||||
| /** | /** | ||||
| * @task hg | * @task hg | ||||
| */ | */ | ||||
| private function executeMercurialCreate() { | private function executeMercurialCreate() { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | /* -( Pulling Subversion Working Copies )---------------------------------- */ | ||||
| */ | */ | ||||
| private function executeSubversionCreate() { | private function executeSubversionCreate() { | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $path = rtrim($repository->getLocalPath(), '/'); | $path = rtrim($repository->getLocalPath(), '/'); | ||||
| execx('svnadmin create -- %s', $path); | execx('svnadmin create -- %s', $path); | ||||
| } | } | ||||
| } | } | ||||
are we implicitly in the.git folder in this case or?