Land to GitHub + support stuff

Summary:
A usable, Land to GitHub flow.

Still to do:
- Refactor all git/hg stratagies to a sane structure.
- Make the dialogs Workflow + explain why it's disabled.
- Show button and request Link Account if GH is enabled, but user is not linked.
- After refreshing token, user ends up in the settings stage.

Hacked something in LandController to be able to show an arbitrary dialog from a strategy.
It's not very nice, but I want to make some more refactoring to the controller/strategy/ies anyway.

Also made PhabricatorRepository::getRemoteURIObject() public, because it was very useful in getting
the domain and path for the repo.

Test Plan:
Went through these flows:
- load revision in hosted, github-backed, non-github backed repos to see button as needed.
- hit land with weak token - sent to refresh it with the extra scope.
- Land to repo I'm not allowed - got proper error message.
- Successfully landed; Failed to apply patch.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T182

Differential Revision: https://secure.phabricator.com/D7555
This commit is contained in:
Aviv Eyal
2013-11-13 17:25:14 -08:00
committed by epriestley
parent 3b257381ad
commit dcf909ba56
6 changed files with 247 additions and 57 deletions

View File

@@ -36,13 +36,14 @@ final class DifferentialRevisionLandController extends DifferentialController {
}
if ($request->isDialogFormPost()) {
$response = null;
$text = '';
try {
$this->attemptLand($revision, $request);
$response = $this->attemptLand($revision, $request);
$title = pht("Success!");
$text = pht("Revision was successfully landed.");
} catch (Exception $ex) {
$title = pht("Failed to land revision");
$text = 'moo';
if ($ex instanceof PhutilProxyException) {
$text = hsprintf(
'%s:<br><pre>%s</pre>',
@@ -55,13 +56,15 @@ final class DifferentialRevisionLandController extends DifferentialController {
->appendChild($text);
}
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->setTitle($title)
->appendChild(phutil_tag('p', array(), $text))
->setSubmitURI('/D'.$revision_id)
->addSubmitButton(pht('Done'));
if ($response instanceof AphrontDialogView) {
$dialog = $response;
} else {
$dialog = id(new AphrontDialogView())
->setUser($viewer)
->setTitle($title)
->appendChild(phutil_tag('p', array(), $text))
->addCancelButton('/D'.$revision_id, pht('Done'));
}
return id(new AphrontDialogResponse())->setDialog($dialog);
}
@@ -108,7 +111,7 @@ final class DifferentialRevisionLandController extends DifferentialController {
$lock = $this->lockRepository($repository);
try {
$this->pushStrategy->processLandRequest(
$response = $this->pushStrategy->processLandRequest(
$request,
$revision,
$repository);
@@ -118,6 +121,7 @@ final class DifferentialRevisionLandController extends DifferentialController {
}
$lock->unlock();
return $response;
}
private function lockRepository($repository) {