Differential D7683 Diff 17352 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 79 Lines • ▼ Show 20 Lines | try { | ||||
| $this->executeMercurialCreate(); | $this->executeMercurialCreate(); | ||||
| } else { | } else { | ||||
| $this->executeSubversionCreate(); | $this->executeSubversionCreate(); | ||||
| } | } | ||||
| } else { | } else { | ||||
| if ($repository->isHosted()) { | if ($repository->isHosted()) { | ||||
| if ($is_git) { | if ($is_git) { | ||||
| $this->installGitHook(); | $this->installGitHook(); | ||||
| } else if ($is_svn) { | |||||
| $this->installSubversionHook(); | |||||
| } else { | } 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 { | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | /* -( Pulling Working Copies )--------------------------------------------- */ | ||||
| private function installHook($path) { | private function installHook($path) { | ||||
| $this->log('%s', pht('Installing commit hook to "%s"...', $path)); | $this->log('%s', pht('Installing commit hook to "%s"...', $path)); | ||||
| $repository = $this->getRepository(); | $repository = $this->getRepository(); | ||||
| $callsign = $repository->getCallsign(); | $callsign = $repository->getCallsign(); | ||||
| $root = dirname(phutil_get_library_root('phabricator')); | $root = dirname(phutil_get_library_root('phabricator')); | ||||
| $bin = $root.'/bin/commit-hook'; | $bin = $root.'/bin/commit-hook'; | ||||
| $cmd = csprintf('exec -- %s %s', $bin, $callsign); | $cmd = csprintf('exec -- %s %s "$@"', $bin, $callsign); | ||||
| $hook = "#!/bin/sh\n{$cmd}\n"; | $hook = "#!/bin/sh\n{$cmd}\n"; | ||||
| Filesystem::writeFile($path, $hook); | Filesystem::writeFile($path, $hook); | ||||
| Filesystem::changePermissions($path, 0755); | Filesystem::changePermissions($path, 0755); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 219 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); | ||||
| } | } | ||||
| /** | |||||
| * @task svn | |||||
| */ | |||||
| private function installSubversionHook() { | |||||
| $repository = $this->getRepository(); | |||||
| $path = $repository->getLocalPath().'hooks/pre-commit'; | |||||
| $this->installHook($path); | |||||
| } | |||||
| } | } | ||||