-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLandRevisionController.php
62 lines (46 loc) · 1.55 KB
/
LandRevisionController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
class LandRevisionController extends AvivUtilController {
const GITHUB_PROVIDER_KEY = 'github:github.com';
const TEST_REPO_GIT_ID = 13850529;
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$revision_id = $request->getInt('revisionID');
$github_repo = $request->getStr('githubRepo');
if ($revision_id != null && strlen($github_repo)) {
$log = id(new LandLocally($request))
->landRevisionLocally($revision_id, $viewer);
if (idx($log, 'landed locally') !== true) {
return $this->build($log);
}
$workdir = $log['workdir'];
$log2 = id(new PushCommitToGithub($request))
->pushLastCommit($workdir, $github_repo, $viewer);
return $this->build($log + $log2);
}
$panel = id(new AphrontPanelView())
->setHeader("Landing to GH demo");
$form = id(new AphrontFormView())
->setUser($viewer);
$form->appendChild(id(new AphrontFormTextControl())
->setName('revisionID')
->setLabel('revision ID')
);
$form->appendChild(id(new AphrontFormTextControl())
->setName('githubRepo')
->setLabel('Github Repo')
->setValue('avivey/test-repo')
->setCaption('should be available from the repo')
);
$form->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Submit'));
$panel->appendChild($form);
return $this->buildApplicationPage(
$panel,
array(
'title' => 'UI Example',
'device' => true,
));
}
}