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
|
|
|
|
|
|
|
|
abstract class DifferentialLandingStrategy {
|
|
|
|
|
|
|
|
public abstract function processLandRequest(
|
|
|
|
AphrontRequest $request,
|
|
|
|
DifferentialRevision $revision,
|
|
|
|
PhabricatorRepository $repository);
|
|
|
|
|
|
|
|
/**
|
2014-01-30 18:07:50 +01:00
|
|
|
* returns PhabricatorActionView or null.
|
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
|
|
|
*/
|
2014-01-30 18:07:50 +01:00
|
|
|
abstract function createMenuItem(
|
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
|
|
|
PhabricatorUser $viewer,
|
|
|
|
DifferentialRevision $revision,
|
|
|
|
PhabricatorRepository $repository);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns PhabricatorActionView which can be attached to the revision view.
|
|
|
|
*/
|
2014-01-30 18:07:50 +01:00
|
|
|
protected function createActionView($revision, $name) {
|
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
|
|
|
$strategy = get_class($this);
|
|
|
|
$revision_id = $revision->getId();
|
|
|
|
return id(new PhabricatorActionView())
|
|
|
|
->setRenderAsForm(true)
|
2014-01-30 18:07:50 +01:00
|
|
|
->setWorkflow(true)
|
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
|
|
|
->setName($name)
|
2014-01-30 18:07:50 +01:00
|
|
|
->setHref("/differential/revision/land/{$revision_id}/{$strategy}/");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if this action should be disabled, and explain why.
|
|
|
|
*
|
|
|
|
* By default, this method checks for push permissions, and for the
|
|
|
|
* revision being Accepted.
|
|
|
|
*
|
|
|
|
* @return FALSE for "not disabled";
|
|
|
|
* Human-readable text explaining why, if it is disabled;
|
|
|
|
*/
|
|
|
|
public function isActionDisabled(
|
|
|
|
PhabricatorUser $viewer,
|
|
|
|
DifferentialRevision $revision,
|
|
|
|
PhabricatorRepository $repository) {
|
|
|
|
|
|
|
|
$status = $revision->getStatus();
|
|
|
|
if ($status != ArcanistDifferentialRevisionStatus::ACCEPTED) {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Only Accepted revisions can be landed.');
|
2014-01-30 18:07:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!PhabricatorPolicyFilter::hasCapability(
|
|
|
|
$viewer,
|
|
|
|
$repository,
|
|
|
|
DiffusionCapabilityPush::CAPABILITY)) {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('You do not have permissions to push to this repository.');
|
2014-01-30 18:07:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* might break if repository is not Git.
|
|
|
|
*/
|
|
|
|
protected function getGitWorkspace(PhabricatorRepository $repository) {
|
|
|
|
try {
|
|
|
|
return DifferentialGetWorkingCopy::getCleanGitWorkspace($repository);
|
|
|
|
} catch (Exception $e) {
|
2013-11-08 20:37:57 +01:00
|
|
|
throw new PhutilProxyException(
|
|
|
|
'Failed to allocate a workspace',
|
|
|
|
$e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* might break if repository is not Mercurial.
|
|
|
|
*/
|
|
|
|
protected function getMercurialWorkspace(PhabricatorRepository $repository) {
|
|
|
|
try {
|
|
|
|
return DifferentialGetWorkingCopy::getCleanMercurialWorkspace(
|
|
|
|
$repository);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
throw new PhutilProxyException(
|
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
|
|
|
'Failed to allocate a workspace',
|
|
|
|
$e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|