Page MenuHomePhabricator

D15516.diff
No OneTemporary

D15516.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
@@ -125,6 +125,11 @@
}
} else {
switch ($this->getIssueRawKind()) {
+ case 'CreateEvent':
+ $ref = idxv($raw, array('payload', 'ref'));
+
+ $repo = $this->getRepositoryFullRawName();
+ return "https://github.com/{$repo}/commits/{$ref}";
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
@@ -205,4 +210,171 @@
return idxv($raw, array('payload', 'issue', 'pull_request'));
}
+ public function getEventFullTitle() {
+ switch ($this->type) {
+ case self::TYPE_ISSUE:
+ $title = $this->getRawIssueEventTitle();
+ break;
+ case self::TYPE_REPOSITORY:
+ $title = $this->getRawRepositoryEventTitle();
+ break;
+ default:
+ $title = pht('Unknown Event Type ("%s")', $this->type);
+ break;
+ }
+
+ return pht(
+ 'GitHub %s %s (%s)',
+ $this->getRepositoryFullRawName(),
+ $this->getTargetObjectName(),
+ $title);
+ }
+
+ private function getTargetObjectName() {
+ if ($this->isPullRequestEvent()) {
+ $number = $this->getRawIssueNumber();
+ return pht('Pull Request #%d', $number);
+ } else if ($this->isIssueEvent()) {
+ $number = $this->getRawIssueNumber();
+ return pht('Issue #%d', $number);
+ } else if ($this->type == self::TYPE_REPOSITORY) {
+ $raw = $this->raw;
+
+
+ $type = idx($raw, 'type');
+ switch ($type) {
+ case 'CreateEvent':
+ $ref = idxv($raw, array('payload', 'ref'));
+ $ref_type = idxv($raw, array('payload', 'ref_type'));
+
+ switch ($ref_type) {
+ case 'branch':
+ return pht('Branch %s', $ref);
+ case 'tag':
+ return pht('Tag %s', $ref);
+ default:
+ return pht('Ref %s', $ref);
+ }
+ break;
+ case 'PushEvent':
+ $ref = idxv($raw, array('payload', 'ref'));
+ if (preg_match('(^refs/heads/)', $ref)) {
+ return pht('Branch %s', substr($ref, strlen('refs/heads/')));
+ } else {
+ return pht('Ref %s', $ref);
+ }
+ break;
+ case 'WatchEvent':
+ $actor = idxv($raw, array('actor', 'login'));
+ return pht('User %s', $actor);
+ }
+
+ return pht('Unknown Object');
+ } else {
+ return pht('Unknown Object');
+ }
+ }
+
+ private function getRawIssueEventTitle() {
+ $raw = $this->raw;
+
+ $action = idxv($raw, array('event'));
+ switch ($action) {
+ case 'assigned':
+ $assignee = idxv($raw, array('assignee', 'login'));
+ $title = pht('Assigned: %s', $assignee);
+ break;
+ case 'closed':
+ $title = pht('Closed');
+ break;
+ case 'demilestoned':
+ $milestone = idxv($raw, array('milestone', 'title'));
+ $title = pht('Removed Milestone: %s', $milestone);
+ break;
+ case 'labeled':
+ $label = idxv($raw, array('label', 'name'));
+ $title = pht('Added Label: %s', $label);
+ break;
+ case 'locked':
+ $title = pht('Locked');
+ break;
+ case 'milestoned':
+ $milestone = idxv($raw, array('milestone', 'title'));
+ $title = pht('Added Milestone: %s', $milestone);
+ break;
+ case 'renamed':
+ $title = pht('Renamed');
+ break;
+ case 'reopened':
+ $title = pht('Reopened');
+ break;
+ case 'unassigned':
+ $assignee = idxv($raw, array('assignee', 'login'));
+ $title = pht('Unassigned: %s', $assignee);
+ break;
+ case 'unlabeled':
+ $label = idxv($raw, array('label', 'name'));
+ $title = pht('Removed Label: %s', $label);
+ break;
+ case 'unlocked':
+ $title = pht('Unlocked');
+ break;
+ default:
+ $title = pht('"%s"', $action);
+ break;
+ }
+
+
+ return $title;
+ }
+
+ private function getRawRepositoryEventTitle() {
+ $raw = $this->raw;
+
+ $type = idx($raw, 'type');
+ switch ($type) {
+ case 'CreateEvent':
+ return pht('Created');
+ case 'PushEvent':
+ $head = idxv($raw, array('payload', 'head'));
+ $head = substr($head, 0, 12);
+ return pht('Pushed: %s', $head);
+ case 'IssuesEvent':
+ $action = idxv($raw, array('payload', 'action'));
+ switch ($action) {
+ case 'closed':
+ return pht('Closed');
+ case 'opened':
+ return pht('Created');
+ case 'reopened':
+ return pht('Reopened');
+ default:
+ return pht('"%s"', $action);
+ }
+ break;
+ case 'IssueCommentEvent':
+ $action = idxv($raw, array('payload', 'action'));
+ switch ($action) {
+ case 'created':
+ return pht('Comment');
+ default:
+ return pht('"%s"', $action);
+ }
+ break;
+ case 'PullRequestEvent':
+ $action = idxv($raw, array('payload', 'action'));
+ switch ($action) {
+ case 'opened':
+ return pht('Created');
+ default:
+ return pht('"%s"', $action);
+ }
+ break;
+ case 'WatchEvent':
+ return pht('Watched');
+ }
+
+ return pht('"%s"', $type);
+ }
+
}
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
@@ -50,6 +50,7 @@
'pull.number' => $event->getPullRequestNumber(),
'id' => $event->getID(),
'uri' => $event->getURI(),
+ 'title.full' => $event->getEventFullTitle(),
);
// 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
@@ -112,5 +112,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583217900,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583217900"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583217900",
+ "title.full": "GitHub epriestley/poems Issue #1 (Assigned: epriestley)"
}
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
@@ -74,5 +74,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218864,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218864"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218864",
+ "title.full": "GitHub epriestley/poems Issue #1 (Closed)"
}
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
@@ -77,5 +77,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218613,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218613"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218613",
+ "title.full": "GitHub epriestley/poems Issue #1 (Removed Milestone: b)"
}
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
@@ -78,5 +78,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583217784,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583217784"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583217784",
+ "title.full": "GitHub epriestley/poems Issue #1 (Added Label: bug)"
}
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
@@ -74,5 +74,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218006,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218006"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218006",
+ "title.full": "GitHub epriestley/poems Issue #1 (Locked)"
}
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
@@ -77,5 +77,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583217866,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583217866"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583217866",
+ "title.full": "GitHub epriestley/poems Issue #1 (Added Milestone: b)"
}
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
@@ -78,5 +78,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218162,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218162"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218162",
+ "title.full": "GitHub epriestley/poems Issue #1 (Renamed)"
}
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
@@ -74,5 +74,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218814,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218814"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218814",
+ "title.full": "GitHub epriestley/poems Issue #1 (Reopened)"
}
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
@@ -112,5 +112,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218511,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218511"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218511",
+ "title.full": "GitHub epriestley/poems Issue #1 (Unassigned: epriestley)"
}
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
@@ -78,5 +78,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218703,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218703"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218703",
+ "title.full": "GitHub epriestley/poems Issue #1 (Removed Label: bug)"
}
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
@@ -74,5 +74,6 @@
"is.pull": false,
"issue.number": 1,
"id": 583218062,
- "uri": "https://github.com/epriestley/poems/issues/1#event-583218062"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-583218062",
+ "title.full": "GitHub epriestley/poems Issue #1 (Unlocked)"
}
diff --git a/src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt b/src/applications/nuance/github/__tests__/repositoryevents/CreateEvent.tag.txt
copy from src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt
copy to src/applications/nuance/github/__tests__/repositoryevents/CreateEvent.tag.txt
--- a/src/applications/nuance/github/__tests__/repositoryevents/WatchEvent.started.txt
+++ b/src/applications/nuance/github/__tests__/repositoryevents/CreateEvent.tag.txt
@@ -1,6 +1,6 @@
{
- "id": "3740950917",
- "type": "WatchEvent",
+ "id": "3784548642",
+ "type": "CreateEvent",
"actor": {
"id": 102631,
"login": "epriestley",
@@ -14,11 +14,16 @@
"url": "https://api.github.com/repos/epriestley/poems"
},
"payload": {
- "action": "started"
+ "ref": "phabricator/diff/400",
+ "ref_type": "tag",
+ "master_branch": "master",
+ "description": "Poems (Mirror)",
+ "pusher_type": "user"
},
"public": true,
- "created_at": "2016-03-09T12:56:28Z"
+ "created_at": "2016-03-19T22:07:56Z"
}
+
~~~~~
{
"repository.name.full": "epriestley/poems",
@@ -26,6 +31,7 @@
"is.pull": false,
"issue.number": null,
"pull.number": null,
- "id": 3740950917,
- "uri": null
+ "id": 3784548642,
+ "uri": "https://github.com/epriestley/poems/commits/phabricator/diff/400",
+ "title.full": "GitHub epriestley/poems Tag phabricator/diff/400 (Created)"
}
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
@@ -159,5 +159,6 @@
"issue.number": null,
"pull.number": 2,
"id": 3740938746,
- "uri": "https://github.com/epriestley/poems/pull/2#issuecomment-194282800"
+ "uri": "https://github.com/epriestley/poems/pull/2#issuecomment-194282800",
+ "title.full": "GitHub epriestley/poems Pull Request #2 (Comment)"
}
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
@@ -96,5 +96,6 @@
"is.pull": false,
"issue.number": 1,
"id": 3733510485,
- "uri": "https://github.com/epriestley/poems/issues/1#issuecomment-193528669"
+ "uri": "https://github.com/epriestley/poems/issues/1#issuecomment-193528669",
+ "title.full": "GitHub epriestley/poems Issue #1 (Comment)"
}
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
@@ -68,5 +68,6 @@
"is.pull": false,
"issue.number": 1,
"id": 3740905151,
- "uri": "https://github.com/epriestley/poems/issues/1#event-3740905151"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3740905151",
+ "title.full": "GitHub epriestley/poems Issue #1 (Closed)"
}
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
@@ -68,5 +68,6 @@
"is.pull": false,
"issue.number": 1,
"id": 3733509737,
- "uri": "https://github.com/epriestley/poems/issues/1#event-3733509737"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3733509737",
+ "title.full": "GitHub epriestley/poems Issue #1 (Created)"
}
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
@@ -68,5 +68,6 @@
"is.pull": false,
"issue.number": 1,
"id": 3740908680,
- "uri": "https://github.com/epriestley/poems/issues/1#event-3740908680"
+ "uri": "https://github.com/epriestley/poems/issues/1#event-3740908680",
+ "title.full": "GitHub epriestley/poems Issue #1 (Reopened)"
}
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
@@ -332,5 +332,6 @@
"issue.number": null,
"pull.number": 2,
"id": 3740936638,
- "uri": "https://github.com/epriestley/poems/pull/2#event-3740936638"
+ "uri": "https://github.com/epriestley/poems/pull/2#event-3740936638",
+ "title.full": "GitHub epriestley/poems Pull Request #2 (Created)"
}
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
@@ -43,5 +43,6 @@
"is.pull": false,
"issue.number": null,
"id": 3498724127,
- "uri": "https://github.com/epriestley/poems/commits/c829132d37c4c1da80d319942a5a1e500632b52f"
+ "uri": "https://github.com/epriestley/poems/commits/c829132d37c4c1da80d319942a5a1e500632b52f",
+ "title.full": "GitHub epriestley/poems Branch master (Pushed: c829132d37c4)"
}
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
@@ -27,5 +27,6 @@
"issue.number": null,
"pull.number": null,
"id": 3740950917,
- "uri": null
+ "uri": null,
+ "title.full": "GitHub epriestley/poems User epriestley (Watched)"
}
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
@@ -16,59 +16,7 @@
}
public function getItemDisplayName(NuanceItem $item) {
- $api_type = $item->getItemProperty('api.type');
- switch ($api_type) {
- case 'issue':
- return $this->getGitHubIssueAPIEventDisplayName($item);
- case 'repository':
- return $this->getGitHubRepositoryAPIEventDisplayName($item);
- default:
- return pht('GitHub Event (Unknown API Type "%s")', $api_type);
- }
- }
-
- private function getGitHubIssueAPIEventDisplayName(NuanceItem $item) {
- $raw = $item->getItemProperty('api.raw', array());
-
- $action = idxv($raw, array('event'));
- $number = idxv($raw, array('issue', 'number'));
-
- return pht('GitHub Issue #%d (%s)', $number, $action);
- }
-
- private function getGitHubRepositoryAPIEventDisplayName(NuanceItem $item) {
- $raw = $item->getItemProperty('api.raw', array());
-
- $repo = idxv($raw, array('repo', 'name'), pht('<unknown/unknown>'));
-
- $type = idx($raw, 'type');
- switch ($type) {
- case 'PushEvent':
- $head = idxv($raw, array('payload', 'head'));
- $head = substr($head, 0, 8);
- $name = pht('Push %s', $head);
- break;
- case 'IssuesEvent':
- $action = idxv($raw, array('payload', 'action'));
- $number = idxv($raw, array('payload', 'issue', 'number'));
- $name = pht('Issue #%d (%s)', $number, $action);
- break;
- case 'IssueCommentEvent':
- $action = idxv($raw, array('payload', 'action'));
- $number = idxv($raw, array('payload', 'issue', 'number'));
- $name = pht('Issue #%d (Comment, %s)', $number, $action);
- break;
- case 'PullRequestEvent':
- $action = idxv($raw, array('payload', 'action'));
- $number = idxv($raw, array('payload', 'pull_request', 'number'));
- $name = pht('Pull Request #%d (%s)', $number, $action);
- break;
- default:
- $name = pht('Unknown Event ("%s")', $type);
- break;
- }
-
- return pht('GitHub %s %s', $repo, $name);
+ return $this->newRawEvent($item)->getEventFullTitle();
}
public function canUpdateItems() {

File Metadata

Mime Type
text/plain
Expires
Fri, May 24, 4:20 AM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6289612
Default Alt Text
D15516.diff (21 KB)

Event Timeline