Land Revision button for hosted git repos
Summary:
ref T182.
Simple approach of clone, patch, push. While waiting for drydock, implement a hackish mutex
setup for the workspace, which should work ok as long as there's only one committer who is
carefull about theses things.
Less obvious note: This is taking the both author and commiter's 'primary email' for the commit -
which might rub some people wrong.
Test Plan:
With a hosted repo, created some diffs and landed them.
Also clicked button for some error cases, got the right error message.
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley
CC: hach-que, Korvin, epriestley, aran
Maniphest Tasks: T182
Differential Revision: https://secure.phabricator.com/D7486
2013-11-05 22:00:12 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Can't find a good place for this, so I'm putting it in the most notably
|
|
|
|
* wrong place.
|
|
|
|
*/
|
|
|
|
final class DifferentialGetWorkingCopy {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates and/or cleans a workspace for the requested repo.
|
|
|
|
*
|
|
|
|
* return ArcanistGitAPI
|
|
|
|
*/
|
|
|
|
public static function getCleanGitWorkspace(
|
|
|
|
PhabricatorRepository $repo) {
|
|
|
|
|
|
|
|
$origin_path = $repo->getLocalPath();
|
|
|
|
|
|
|
|
$path = rtrim($origin_path, '/');
|
|
|
|
$path = $path . '__workspace';
|
|
|
|
|
|
|
|
if (!Filesystem::pathExists($path)) {
|
|
|
|
$repo->execxLocalCommand(
|
|
|
|
'clone -- file://%s %s',
|
|
|
|
$origin_path,
|
|
|
|
$path);
|
|
|
|
}
|
|
|
|
|
|
|
|
$workspace = new ArcanistGitAPI($path);
|
|
|
|
$workspace->execxLocal('clean -f -d');
|
|
|
|
$workspace->execxLocal('checkout master');
|
|
|
|
$workspace->execxLocal('fetch');
|
|
|
|
$workspace->execxLocal('reset --hard origin/master');
|
|
|
|
$workspace->reloadWorkingCopy();
|
|
|
|
|
|
|
|
return $workspace;
|
|
|
|
}
|
|
|
|
|
2013-11-08 20:37:57 +01:00
|
|
|
/**
|
|
|
|
* Creates and/or cleans a workspace for the requested repo.
|
|
|
|
*
|
|
|
|
* return ArcanistMercurialAPI
|
|
|
|
*/
|
|
|
|
public static function getCleanMercurialWorkspace(
|
|
|
|
PhabricatorRepository $repo) {
|
|
|
|
|
|
|
|
$origin_path = $repo->getLocalPath();
|
|
|
|
|
|
|
|
$path = rtrim($origin_path, '/');
|
|
|
|
$path = $path . '__workspace';
|
|
|
|
|
|
|
|
if (!Filesystem::pathExists($path)) {
|
|
|
|
$repo->execxLocalCommand(
|
|
|
|
'clone -- file://%s %s',
|
|
|
|
$origin_path,
|
|
|
|
$path);
|
|
|
|
}
|
|
|
|
|
|
|
|
$workspace = new ArcanistMercurialAPI($path);
|
|
|
|
$workspace->execxLocal('pull');
|
|
|
|
$workspace->execxLocal('update --clean default');
|
|
|
|
$workspace->reloadWorkingCopy();
|
|
|
|
|
|
|
|
return $workspace;
|
|
|
|
}
|
|
|
|
|
Land Revision button for hosted git repos
Summary:
ref T182.
Simple approach of clone, patch, push. While waiting for drydock, implement a hackish mutex
setup for the workspace, which should work ok as long as there's only one committer who is
carefull about theses things.
Less obvious note: This is taking the both author and commiter's 'primary email' for the commit -
which might rub some people wrong.
Test Plan:
With a hosted repo, created some diffs and landed them.
Also clicked button for some error cases, got the right error message.
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley
CC: hach-que, Korvin, epriestley, aran
Maniphest Tasks: T182
Differential Revision: https://secure.phabricator.com/D7486
2013-11-05 22:00:12 +01:00
|
|
|
}
|