Differential D20435 Diff 48789 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 136 Lines • ▼ Show 20 Lines | try { | ||||
$this->installMercurialHook(); | $this->installMercurialHook(); | ||||
} | } | ||||
foreach ($repository->getHookDirectories() as $directory) { | foreach ($repository->getHookDirectories() as $directory) { | ||||
$this->installHookDirectory($directory); | $this->installHookDirectory($directory); | ||||
} | } | ||||
} | } | ||||
if ($is_git) { | |||||
$this->updateGitWorkingCopyConfiguration(); | |||||
} | |||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$this->abortPull( | $this->abortPull( | ||||
pht( | pht( | ||||
"Pull of '%s' failed: %s", | "Pull of '%s' failed: %s", | ||||
$repository->getDisplayName(), | $repository->getDisplayName(), | ||||
$ex->getMessage()), | $ex->getMessage()), | ||||
$ex); | $ex); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | if ($repository->isWorkingCopyBare()) { | ||||
$path = '/hooks/pre-receive'; | $path = '/hooks/pre-receive'; | ||||
} else { | } else { | ||||
$path = '/.git/hooks/pre-receive'; | $path = '/.git/hooks/pre-receive'; | ||||
} | } | ||||
$this->installHook($root.$path); | $this->installHook($root.$path); | ||||
} | } | ||||
private function updateGitWorkingCopyConfiguration() { | |||||
$repository = $this->getRepository(); | |||||
// See T5963. When you "git clone" from a remote with no "master", the | |||||
// client warns you that it isn't sure what it should check out as an | |||||
// initial state: | |||||
// warning: remote HEAD refers to nonexistent ref, unable to checkout | |||||
// We can tell the client what it should check out by making "HEAD" | |||||
// point somewhere. However: | |||||
// | |||||
// (1) If we don't set "receive.denyDelteCurrent" to "ignore" and a user | |||||
amckinley: `denyDeleteCurrent` | |||||
Done Inline ActionsOops, missed this. I'll get it in a followup. epriestley: Oops, missed this. I'll get it in a followup. | |||||
// tries to delete the default branch, Git raises an error and refuses. | |||||
// We want to allow this; we already have sufficient protections around | |||||
// dangerous changes and do not need to special case the default branch. | |||||
// | |||||
// (2) A repository may have a nonexistent default branch configured. | |||||
// For now, we just respect configuration. This will raise a warning when | |||||
// users clone the repository. | |||||
// | |||||
// In any case, these changes are both advisory, so ignore any errors we | |||||
// may encounter. | |||||
// We do this for both hosted and observed repositories. Although it is | |||||
// not terribly common to clone from Phabricator's copy of an observed | |||||
// repository, it works fine and makes sense occasionally. | |||||
if ($repository->isWorkingCopyBare()) { | |||||
$repository->execLocalCommand( | |||||
'config -- receive.denyDeleteCurrent ignore'); | |||||
$repository->execLocalCommand( | |||||
'symbolic-ref HEAD %s', | |||||
'refs/heads/'.$repository->getDefaultBranch()); | |||||
} | |||||
} | |||||
private function loadGitRemoteRefs( | private function loadGitRemoteRefs( | ||||
PhabricatorRepository $repository, | PhabricatorRepository $repository, | ||||
PhutilOpaqueEnvelope $remote_envelope) { | PhutilOpaqueEnvelope $remote_envelope) { | ||||
$ref_rules = $this->getGitRefRules($repository); | $ref_rules = $this->getGitRefRules($repository); | ||||
// NOTE: "git ls-remote" does not support "--" until circa January 2016. | // NOTE: "git ls-remote" does not support "--" until circa January 2016. | ||||
// See T12416. None of the flags to "ls-remote" appear dangerous, but | // See T12416. None of the flags to "ls-remote" appear dangerous, but | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |
denyDeleteCurrent