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.
|
|
|
|
*/
|
2015-06-15 10:02:26 +02:00
|
|
|
final class DifferentialGetWorkingCopy extends Phobject {
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* 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, '/');
|
2014-06-10 01:03:58 +02:00
|
|
|
$path = $path.'__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
|
|
|
|
|
|
|
if (!Filesystem::pathExists($path)) {
|
|
|
|
$repo->execxLocalCommand(
|
|
|
|
'clone -- file://%s %s',
|
|
|
|
$origin_path,
|
|
|
|
$path);
|
2013-12-31 00:22:31 +01:00
|
|
|
|
|
|
|
if (!$repo->isHosted()) {
|
|
|
|
id(new ArcanistGitAPI($path))->execxLocal(
|
|
|
|
'remote set-url origin %s',
|
|
|
|
$repo->getRemoteURI());
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
$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, '/');
|
2014-06-10 01:03:58 +02:00
|
|
|
$path = $path.'__workspace';
|
2013-11-08 20:37:57 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|