1
0
Fork 0
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:
epriestley 2013-10-26 21:08:24 -07:00
parent d8bda7c66e
commit 59922b78b9
6 changed files with 17 additions and 14 deletions

View file

@ -40,6 +40,7 @@ final class DiffusionRepositoryController extends DiffusionController {
}
}
}
$history_exception = null;
} catch (Exception $ex) {
$history_results = null;
$history = null;
@ -68,6 +69,7 @@ final class DiffusionRepositoryController extends DiffusionController {
}
}
$browse_exception = null;
} catch (Exception $ex) {
$browse_results = null;
$browse_paths = null;

View file

@ -37,8 +37,12 @@ final class DiffusionRepositoryEditBranchesController
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_default = $repository->getHumanReadableDetail('default-branch');
$v_track = $repository->getHumanReadableDetail('branch-filter');
$v_autoclose = $repository->getHumanReadableDetail('close-commits-filter');
$v_track = $repository->getHumanReadableDetail(
'branch-filter',
array());
$v_autoclose = $repository->getHumanReadableDetail(
'close-commits-filter',
array());
if ($request->isFormPost()) {
$v_default = $request->getStr('default');

View file

@ -7,8 +7,7 @@ extends DiffusionStableCommitNameQuery {
$repository = $this->getRepository();
$branch = $this->getBranch();
list($stdout) = $repository->execxLocalCommand(
'rev-parse --verify %s/%s',
DiffusionBranchInformation::DEFAULT_GIT_REMOTE,
'rev-parse --verify %s',
$branch);
$commit = trim($stdout);

View file

@ -31,8 +31,7 @@ final class DiffusionGitRequest extends DiffusionRequest {
if ($this->commit) {
return $this->commit;
}
$remote = DiffusionBranchInformation::DEFAULT_GIT_REMOTE;
return $remote.'/'.$this->getBranch();
return $this->getBranch();
}
}

View file

@ -99,7 +99,7 @@ final class PhabricatorRepositoryPullEngine
$repository = $this->getRepository();
$repository->execxRemoteCommand(
'clone --origin origin %s %s',
'clone --bare %s %s',
$repository->getRemoteURI(),
rtrim($repository->getLocalPath(), '/'));
}
@ -149,12 +149,11 @@ final class PhabricatorRepositoryPullEngine
$repo_path = rtrim($stdout, "\n");
if (empty($repo_path)) {
$err = true;
$message =
"Expected to find a git repository at '{$path}', but ".
"there was no result from `git rev-parse --show-toplevel`. ".
"Something is misconfigured or broken. The git repository ".
"may be inside a '.git/' directory.";
// This can mean one of two things: we're in a bare repository, or
// we're inside a git repository inside another git repository. Since
// the first is dramatically more likely now that we perform bare
// clones and I don't have a great way to test for the latter, assume
// we're OK.
} else if (!Filesystem::pathsAreEquivalent($repo_path, $path)) {
$err = true;
$message =

View file

@ -8,7 +8,7 @@ final class PhabricatorWorkingCopyPullTestCase
$this->assertEqual(
true,
Filesystem::pathExists($repo->getLocalPath().'/.git'));
Filesystem::pathExists($repo->getLocalPath().'/HEAD'));
}
public function testHgPullBasic() {