mirror of
https://we.phorge.it/source/phorge.git
synced 2024-09-20 09:18:48 +02:00
Make Phabricator clone bare git repositories
Summary: This doesn't really impact anything very much, but is a little cleaner than cloning repositories with a working copy. It's somewhat important for allowing pushes, because you can't push to a checked-out branch. Mercurial has a similar option (`--noupdate`) but leave that alone for now. The origin stuff was mostly for sanity/explicitness purposes -- I believe it's safe to remove in all non-ridiculous cases. Git fails with it in bare repositories (it automatically creates an `origin`, but doesn't create the local refs for it, or something). Test Plan: Nuked a repo, re-cloned it, pulled and updated it several times. Browsed both bare and non-bare repos in Diffusion. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2230 Differential Revision: https://secure.phabricator.com/D7430
This commit is contained in:
parent
d8bda7c66e
commit
59922b78b9
6 changed files with 17 additions and 14 deletions
|
@ -40,6 +40,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$history_exception = null;
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$history_results = null;
|
$history_results = null;
|
||||||
$history = null;
|
$history = null;
|
||||||
|
@ -68,6 +69,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$browse_exception = null;
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$browse_results = null;
|
$browse_results = null;
|
||||||
$browse_paths = null;
|
$browse_paths = null;
|
||||||
|
|
|
@ -37,8 +37,12 @@ final class DiffusionRepositoryEditBranchesController
|
||||||
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
|
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
|
||||||
|
|
||||||
$v_default = $repository->getHumanReadableDetail('default-branch');
|
$v_default = $repository->getHumanReadableDetail('default-branch');
|
||||||
$v_track = $repository->getHumanReadableDetail('branch-filter');
|
$v_track = $repository->getHumanReadableDetail(
|
||||||
$v_autoclose = $repository->getHumanReadableDetail('close-commits-filter');
|
'branch-filter',
|
||||||
|
array());
|
||||||
|
$v_autoclose = $repository->getHumanReadableDetail(
|
||||||
|
'close-commits-filter',
|
||||||
|
array());
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$v_default = $request->getStr('default');
|
$v_default = $request->getStr('default');
|
||||||
|
|
|
@ -7,8 +7,7 @@ extends DiffusionStableCommitNameQuery {
|
||||||
$repository = $this->getRepository();
|
$repository = $this->getRepository();
|
||||||
$branch = $this->getBranch();
|
$branch = $this->getBranch();
|
||||||
list($stdout) = $repository->execxLocalCommand(
|
list($stdout) = $repository->execxLocalCommand(
|
||||||
'rev-parse --verify %s/%s',
|
'rev-parse --verify %s',
|
||||||
DiffusionBranchInformation::DEFAULT_GIT_REMOTE,
|
|
||||||
$branch);
|
$branch);
|
||||||
|
|
||||||
$commit = trim($stdout);
|
$commit = trim($stdout);
|
||||||
|
|
|
@ -31,8 +31,7 @@ final class DiffusionGitRequest extends DiffusionRequest {
|
||||||
if ($this->commit) {
|
if ($this->commit) {
|
||||||
return $this->commit;
|
return $this->commit;
|
||||||
}
|
}
|
||||||
$remote = DiffusionBranchInformation::DEFAULT_GIT_REMOTE;
|
return $this->getBranch();
|
||||||
return $remote.'/'.$this->getBranch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ final class PhabricatorRepositoryPullEngine
|
||||||
$repository = $this->getRepository();
|
$repository = $this->getRepository();
|
||||||
|
|
||||||
$repository->execxRemoteCommand(
|
$repository->execxRemoteCommand(
|
||||||
'clone --origin origin %s %s',
|
'clone --bare %s %s',
|
||||||
$repository->getRemoteURI(),
|
$repository->getRemoteURI(),
|
||||||
rtrim($repository->getLocalPath(), '/'));
|
rtrim($repository->getLocalPath(), '/'));
|
||||||
}
|
}
|
||||||
|
@ -149,12 +149,11 @@ final class PhabricatorRepositoryPullEngine
|
||||||
$repo_path = rtrim($stdout, "\n");
|
$repo_path = rtrim($stdout, "\n");
|
||||||
|
|
||||||
if (empty($repo_path)) {
|
if (empty($repo_path)) {
|
||||||
$err = true;
|
// This can mean one of two things: we're in a bare repository, or
|
||||||
$message =
|
// we're inside a git repository inside another git repository. Since
|
||||||
"Expected to find a git repository at '{$path}', but ".
|
// the first is dramatically more likely now that we perform bare
|
||||||
"there was no result from `git rev-parse --show-toplevel`. ".
|
// clones and I don't have a great way to test for the latter, assume
|
||||||
"Something is misconfigured or broken. The git repository ".
|
// we're OK.
|
||||||
"may be inside a '.git/' directory.";
|
|
||||||
} else if (!Filesystem::pathsAreEquivalent($repo_path, $path)) {
|
} else if (!Filesystem::pathsAreEquivalent($repo_path, $path)) {
|
||||||
$err = true;
|
$err = true;
|
||||||
$message =
|
$message =
|
||||||
|
|
|
@ -8,7 +8,7 @@ final class PhabricatorWorkingCopyPullTestCase
|
||||||
|
|
||||||
$this->assertEqual(
|
$this->assertEqual(
|
||||||
true,
|
true,
|
||||||
Filesystem::pathExists($repo->getLocalPath().'/.git'));
|
Filesystem::pathExists($repo->getLocalPath().'/HEAD'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHgPullBasic() {
|
public function testHgPullBasic() {
|
||||||
|
|
Loading…
Reference in a new issue