Page MenuHomePhabricator

D15505.diff
No OneTemporary

D15505.diff

diff --git a/src/applications/nuance/github/NuanceGitHubRawEvent.php b/src/applications/nuance/github/NuanceGitHubRawEvent.php
--- a/src/applications/nuance/github/NuanceGitHubRawEvent.php
+++ b/src/applications/nuance/github/NuanceGitHubRawEvent.php
@@ -78,6 +78,68 @@
return $this->getRawIssueNumber();
}
+
+ public function getID() {
+ $raw = $this->raw;
+
+ $id = idx($raw, 'id');
+ if ($id) {
+ return (int)$id;
+ }
+
+ return null;
+ }
+
+ public function getURI() {
+ $raw = $this->raw;
+
+ if ($this->isIssueEvent()) {
+ if ($this->type == self::TYPE_ISSUE) {
+ $uri = idxv($raw, array('issue', 'html_url'));
+ $uri = $uri.'#event-'.$this->getID();
+ } else {
+ $uri = idxv($raw, array('payload', 'issue', 'html_url'));
+ $uri = $uri.'#event-'.$this->getID();
+ }
+ } else if ($this->isPullRequestEvent()) {
+ if ($this->type == self::TYPE_ISSUE) {
+ $uri = idxv($raw, array('issue', 'html_url'));
+ $uri = $uri.'#event-'.$this->getID();
+ } else {
+ // The format of pull request events varies so we need to fish around
+ // a bit to find the correct URI.
+ $uri = idxv($raw, array('payload', 'pull_request', 'html_url'));
+ if (!$uri) {
+ $uri = idxv($raw, array('payload', 'issue', 'html_url'));
+ }
+ $uri = $uri.'#event-'.$this->getID();
+ }
+ } else {
+ switch ($this->getIssueRawKind()) {
+ case 'PushEvent':
+ // These don't really have a URI since there may be multiple commits
+ // involved and GitHub doesn't bundle the push as an object on its
+ // own. Just try to find the URI for the log. The API also does
+ // not return any HTML URI for these events.
+
+ $head = idxv($raw, array('payload', 'head'));
+ if ($head === null) {
+ return null;
+ }
+
+ $repo = $this->getRepositoryFullRawName();
+ return "https://github.com/{$repo}/commits/{$head}";
+ case 'WatchEvent':
+ // These have no reasonable URI.
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ return $uri;
+ }
+
private function getRepositoryFullRawName() {
$raw = $this->raw;
diff --git a/src/applications/nuance/github/__tests__/NuanceGitHubRawEventTestCase.php b/src/applications/nuance/github/__tests__/NuanceGitHubRawEventTestCase.php
--- a/src/applications/nuance/github/__tests__/NuanceGitHubRawEventTestCase.php
+++ b/src/applications/nuance/github/__tests__/NuanceGitHubRawEventTestCase.php
@@ -48,6 +48,8 @@
'is.pull' => $event->isPullRequestEvent(),
'issue.number' => $event->getIssueNumber(),
'pull.number' => $event->getPullRequestNumber(),
+ 'id' => $event->getID(),
+ 'uri' => $event->getURI(),
);
// Only verify the keys which are actually present in the test. This
diff --git a/src/applications/nuance/github/__tests__/issueevents/assigned.txt b/src/applications/nuance/github/__tests__/issueevents/assigned.txt
--- a/src/applications/nuance/github/__tests__/issueevents/assigned.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/assigned.txt
@@ -110,5 +110,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583217900,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583217900"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/closed.txt b/src/applications/nuance/github/__tests__/issueevents/closed.txt
--- a/src/applications/nuance/github/__tests__/issueevents/closed.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/closed.txt
@@ -72,5 +72,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218864,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218864"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/demilestoned.txt b/src/applications/nuance/github/__tests__/issueevents/demilestoned.txt
--- a/src/applications/nuance/github/__tests__/issueevents/demilestoned.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/demilestoned.txt
@@ -75,5 +75,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218613,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218613"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/labeled.txt b/src/applications/nuance/github/__tests__/issueevents/labeled.txt
--- a/src/applications/nuance/github/__tests__/issueevents/labeled.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/labeled.txt
@@ -76,5 +76,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583217784,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583217784"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/locked.txt b/src/applications/nuance/github/__tests__/issueevents/locked.txt
--- a/src/applications/nuance/github/__tests__/issueevents/locked.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/locked.txt
@@ -72,5 +72,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218006,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218006"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/milestoned.txt b/src/applications/nuance/github/__tests__/issueevents/milestoned.txt
--- a/src/applications/nuance/github/__tests__/issueevents/milestoned.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/milestoned.txt
@@ -75,5 +75,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583217866,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583217866"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/renamed.txt b/src/applications/nuance/github/__tests__/issueevents/renamed.txt
--- a/src/applications/nuance/github/__tests__/issueevents/renamed.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/renamed.txt
@@ -76,5 +76,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218162,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218162"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/reopened.txt b/src/applications/nuance/github/__tests__/issueevents/reopened.txt
--- a/src/applications/nuance/github/__tests__/issueevents/reopened.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/reopened.txt
@@ -72,5 +72,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218814,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218814"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/unassigned.txt b/src/applications/nuance/github/__tests__/issueevents/unassigned.txt
--- a/src/applications/nuance/github/__tests__/issueevents/unassigned.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/unassigned.txt
@@ -110,5 +110,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218511,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218511"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/unlabeled.txt b/src/applications/nuance/github/__tests__/issueevents/unlabeled.txt
--- a/src/applications/nuance/github/__tests__/issueevents/unlabeled.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/unlabeled.txt
@@ -76,5 +76,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218703,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218703"
}
diff --git a/src/applications/nuance/github/__tests__/issueevents/unlocked.txt b/src/applications/nuance/github/__tests__/issueevents/unlocked.txt
--- a/src/applications/nuance/github/__tests__/issueevents/unlocked.txt
+++ b/src/applications/nuance/github/__tests__/issueevents/unlocked.txt
@@ -72,5 +72,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 583218062,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218062"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.pull.txt b/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.pull.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.pull.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.pull.txt
@@ -157,5 +157,7 @@
"is.issue": false,
"is.pull": true,
"issue.number": null,
- "pull.number": 2
+ "pull.number": 2,
+ "id": 3740938746,
+ "uri": "https://github.com/epriestley/poems/pull/2#event-3740938746"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.txt b/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/IssueCommentEvent.created.txt
@@ -94,5 +94,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 3733510485,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3733510485"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.closed.txt b/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.closed.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.closed.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.closed.txt
@@ -66,5 +66,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 3740905151,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3740905151"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.opened.txt b/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.opened.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.opened.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.opened.txt
@@ -66,5 +66,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 3733509737,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3733509737"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.reopened.txt b/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.reopened.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.reopened.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/IssuesEvent.reopened.txt
@@ -66,5 +66,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": true,
"is.pull": false,
- "issue.number": 1
+ "issue.number": 1,
+ "id": 3740908680,
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3740908680"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/PullRequestEvent.opened.txt b/src/applications/nuance/github/__tests__/repositoryevents/PullRequestEvent.opened.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/PullRequestEvent.opened.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/PullRequestEvent.opened.txt
@@ -330,5 +330,7 @@
"is.issue": false,
"is.pull": true,
"issue.number": null,
- "pull.number": 2
+ "pull.number": 2,
+ "id": 3740936638,
+ "uri": "https://github.com/epriestley/poems/pull/2#event-3740936638"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/PushEvent.txt b/src/applications/nuance/github/__tests__/repositoryevents/PushEvent.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/PushEvent.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/PushEvent.txt
@@ -41,5 +41,7 @@
"repository.name.full": "epriestley/poems",
"is.issue": false,
"is.pull": false,
- "issue.number": null
+ "issue.number": null,
+ "id": 3498724127,
+ "uri": "https://github.com/epriestley/poems/commits/c829132d37c4c1da80d319942a5a1e500632b52f"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt b/src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt
@@ -25,5 +25,7 @@
"is.issue": false,
"is.pull": false,
"issue.number": null,
- "pull.number": null
+ "pull.number": null,
+ "id": 3740950917,
+ "uri": null
}
diff --git a/src/applications/nuance/item/NuanceGitHubEventItemType.php b/src/applications/nuance/item/NuanceGitHubEventItemType.php
--- a/src/applications/nuance/item/NuanceGitHubEventItemType.php
+++ b/src/applications/nuance/item/NuanceGitHubEventItemType.php
@@ -186,4 +186,47 @@
return null;
}
+ protected function newItemView(NuanceItem $item) {
+ $content = array();
+
+ $content[] = $this->newGitHubEventItemPropertyBox($item);
+
+ return $content;
+ }
+
+ private function newGitHubEventItemPropertyBox($item) {
+ $viewer = $this->getViewer();
+
+ $property_list = id(new PHUIPropertyListView())
+ ->setViewer($viewer);
+
+ $event = $this->newRawEvent($item);
+
+ $property_list->addProperty(
+ pht('GitHub Event ID'),
+ $event->getID());
+
+ $event_uri = $event->getURI();
+ if ($event_uri && PhabricatorEnv::isValidRemoteURIForLink($event_uri)) {
+ $event_uri = phutil_tag(
+ 'a',
+ array(
+ 'href' => $event_uri,
+ ),
+ $event_uri);
+ }
+
+ if ($event_uri) {
+ $property_list->addProperty(
+ pht('GitHub Event URI'),
+ $event_uri);
+ }
+
+ return id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Event Properties'))
+ ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
+ ->appendChild($property_list);
+ }
+
+
}
diff --git a/src/applications/nuance/item/NuanceItemType.php b/src/applications/nuance/item/NuanceItemType.php
--- a/src/applications/nuance/item/NuanceItemType.php
+++ b/src/applications/nuance/item/NuanceItemType.php
@@ -32,7 +32,7 @@
return $this->newItemView($item);
}
- protected function newItemView() {
+ protected function newItemView(NuanceItem $item) {
return null;
}

File Metadata

Mime Type
text/plain
Expires
May 9 2024, 10:33 PM (5 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6274646
Default Alt Text
D15505.diff (15 KB)

Event Timeline