1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Pick better GitHub URIs for comment events

Summary: Ref T10538. Boundless joy.

Test Plan: Unit tests.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10538

Differential Revision: https://secure.phabricator.com/D15510
This commit is contained in:
epriestley 2016-03-22 15:20:33 -07:00
parent 1885c4e03b
commit dac07921f7
3 changed files with 17 additions and 12 deletions

View file

@ -93,15 +93,7 @@ final class NuanceGitHubRawEvent extends Phobject {
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->isIssueEvent() || $this->isPullRequestEvent()) {
if ($this->type == self::TYPE_ISSUE) {
$uri = idxv($raw, array('issue', 'html_url'));
$uri = $uri.'#event-'.$this->getID();
@ -109,10 +101,23 @@ final class NuanceGitHubRawEvent extends Phobject {
// 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'));
$need_anchor = true;
// For comments, we get a different anchor to link to the comment. In
// this case, the URI comes with an anchor already.
if (!$uri) {
$uri = idxv($raw, array('payload', 'comment', 'html_url'));
$need_anchor = false;
}
if (!$uri) {
$uri = idxv($raw, array('payload', 'issue', 'html_url'));
$need_anchor = true;
}
if ($need_anchor) {
$uri = $uri.'#event-'.$this->getID();
}
$uri = $uri.'#event-'.$this->getID();
}
} else {
switch ($this->getIssueRawKind()) {

View file

@ -159,5 +159,5 @@
"issue.number": null,
"pull.number": 2,
"id": 3740938746,
"uri": "https://github.com/epriestley/poems/pull/2#event-3740938746"
"uri": "https://github.com/epriestley/poems/pull/2#issuecomment-194282800"
}

View file

@ -96,5 +96,5 @@
"is.pull": false,
"issue.number": 1,
"id": 3733510485,
"uri": "https://github.com/epriestley/poems/issues/1#event-3733510485"
"uri": "https://github.com/epriestley/poems/issues/1#issuecomment-193528669"
}