Differential D8706 Diff 20651 src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
Show First 20 Lines • Show All 688 Lines • ▼ Show 20 Lines | if ($repository->isTracked()) { | ||||
->setIcon('warning') | ->setIcon('warning') | ||||
->setTarget(pht('Repository Inactive')) | ->setTarget(pht('Repository Inactive')) | ||||
->setNote( | ->setNote( | ||||
pht('Activate this repository to begin or resume import.'))); | pht('Activate this repository to begin or resume import.'))); | ||||
return $view; | return $view; | ||||
} | } | ||||
$binaries = array(); | $binaries = array(); | ||||
$svnlook_check = false; | |||||
switch ($repository->getVersionControlSystem()) { | switch ($repository->getVersionControlSystem()) { | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | ||||
$binaries[] = 'git'; | $binaries[] = 'git'; | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
$binaries[] = 'svn'; | $binaries[] = 'svn'; | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | ||||
$binaries[] = 'hg'; | $binaries[] = 'hg'; | ||||
break; | break; | ||||
} | } | ||||
if ($repository->isHosted()) { | if ($repository->isHosted()) { | ||||
if ($repository->getServeOverHTTP() != PhabricatorRepository::SERVE_OFF) { | if ($repository->getServeOverHTTP() != PhabricatorRepository::SERVE_OFF) { | ||||
switch ($repository->getVersionControlSystem()) { | switch ($repository->getVersionControlSystem()) { | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | ||||
$binaries[] = 'git-http-backend'; | $binaries[] = 'git-http-backend'; | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
$binaries[] = 'svnserve'; | $binaries[] = 'svnserve'; | ||||
$binaries[] = 'svnadmin'; | $binaries[] = 'svnadmin'; | ||||
$binaries[] = 'svnlook'; | |||||
$svnlook_check = true; | |||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | ||||
$binaries[] = 'hg'; | $binaries[] = 'hg'; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if ($repository->getServeOverSSH() != PhabricatorRepository::SERVE_OFF) { | if ($repository->getServeOverSSH() != PhabricatorRepository::SERVE_OFF) { | ||||
switch ($repository->getVersionControlSystem()) { | switch ($repository->getVersionControlSystem()) { | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: | ||||
$binaries[] = 'git-receive-pack'; | $binaries[] = 'git-receive-pack'; | ||||
$binaries[] = 'git-upload-pack'; | $binaries[] = 'git-upload-pack'; | ||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: | ||||
$binaries[] = 'svnserve'; | $binaries[] = 'svnserve'; | ||||
$binaries[] = 'svnadmin'; | $binaries[] = 'svnadmin'; | ||||
$binaries[] = 'svnlook'; | |||||
$svnlook_check = true; | |||||
break; | break; | ||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: | ||||
$binaries[] = 'hg'; | $binaries[] = 'hg'; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
$binaries = array_unique($binaries); | $binaries = array_unique($binaries); | ||||
foreach ($binaries as $binary) { | foreach ($binaries as $binary) { | ||||
$where = Filesystem::resolveBinary($binary); | $where = Filesystem::resolveBinary($binary); | ||||
if (!$where) { | if (!$where) { | ||||
$config_href = '/config/edit/environment.append-paths/'; | |||||
$config_link = phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => $config_href, | |||||
), | |||||
'environment.append-paths'); | |||||
$view->addItem( | $view->addItem( | ||||
id(new PHUIStatusItemView()) | id(new PHUIStatusItemView()) | ||||
->setIcon('warning-red') | ->setIcon('warning-red') | ||||
->setTarget( | ->setTarget( | ||||
pht('Missing Binary %s', phutil_tag('tt', array(), $binary))) | pht('Missing Binary %s', phutil_tag('tt', array(), $binary))) | ||||
->setNote(pht( | ->setNote(pht( | ||||
"Unable to find this binary in the webserver's PATH. You may ". | "Unable to find this binary in the webserver's PATH. You may ". | ||||
"need to configure %s.", | "need to configure %s.", | ||||
$config_link))); | $this->getEnvConfigLink()))); | ||||
} else { | } else { | ||||
$view->addItem( | $view->addItem( | ||||
id(new PHUIStatusItemView()) | id(new PHUIStatusItemView()) | ||||
->setIcon('accept-green') | ->setIcon('accept-green') | ||||
->setTarget( | ->setTarget( | ||||
pht('Found Binary %s', phutil_tag('tt', array(), $binary))) | pht('Found Binary %s', phutil_tag('tt', array(), $binary))) | ||||
->setNote(phutil_tag('tt', array(), $where))); | ->setNote(phutil_tag('tt', array(), $where))); | ||||
} | } | ||||
} | } | ||||
// This gets checked generically above. However, for svn commit hooks, we | |||||
// need this to be in environment.append-paths because subversion strips | |||||
// PATH. | |||||
if ($svnlook_check) { | |||||
$where = Filesystem::resolveBinary('svnlook'); | |||||
if ($where) { | |||||
$path = substr($where, 0, strlen($where) - strlen('svnlook')); | |||||
$dirs = PhabricatorEnv::getEnvConfig('environment.append-paths'); | |||||
$in_path = false; | |||||
epriestley: `Filesystem::isDescendant()` might be //slightly// more correct than a straight path comparison… | |||||
foreach ($dirs as $dir) { | |||||
if (Filesystem::isDescendant($path, $dir)) { | |||||
$in_path = true; | |||||
break; | |||||
} | |||||
} | |||||
if (!$in_path) { | |||||
$view->addItem( | |||||
id(new PHUIStatusItemView()) | |||||
->setIcon('warning-red') | |||||
->setTarget( | |||||
pht('Missing Binary %s', phutil_tag('tt', array(), $binary))) | |||||
->setNote(pht( | |||||
'Unable to find this binary in `environment.append-paths`. '. | |||||
'You need to configure %s and include %s.', | |||||
$this->getEnvConfigLink(), | |||||
$path))); | |||||
} | |||||
} | |||||
} | |||||
$doc_href = PhabricatorEnv::getDocLink('Managing Daemons with phd'); | $doc_href = PhabricatorEnv::getDocLink('Managing Daemons with phd'); | ||||
$daemon_instructions = pht( | $daemon_instructions = pht( | ||||
'Use %s to start daemons. See %s.', | 'Use %s to start daemons. See %s.', | ||||
phutil_tag('tt', array(), 'bin/phd start'), | phutil_tag('tt', array(), 'bin/phd start'), | ||||
phutil_tag( | phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
▲ Show 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | foreach ($mirrors as $mirror) { | ||||
->setWorkflow(true)); | ->setWorkflow(true)); | ||||
$mirror_list->addItem($item); | $mirror_list->addItem($item); | ||||
} | } | ||||
return $mirror_list; | return $mirror_list; | ||||
} | } | ||||
private function getEnvConfigLink() { | |||||
$config_href = '/config/edit/environment.append-paths/'; | |||||
return phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => $config_href, | |||||
), | |||||
'environment.append-paths'); | |||||
} | |||||
} | } |
Filesystem::isDescendant() might be slightly more correct than a straight path comparison, and cover some cases involving symlinks.