diff --git a/app/Analyzers/GitHub/Events/CommitCommentEvent.php b/app/Analyzers/GitHub/Events/CommitCommentEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/CommitCommentEvent.php @@ -0,0 +1,38 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * CommitCommentEvent payload analyzer + * + * @link https://developer.github.com/v3/activity/events/types/#commitcommentevent + */ +class CommitCommentEvent extends Event { + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + $comment = $this->payload->comment; + + return trans( + 'GitHub.EventsDescriptions.CommitCommentEvent', + [ + 'author' => $comment->user->login, + 'commit' => substr($comment->commit_id, 0, 8), + 'excerpt' => self::cut($comment->body), + ] + ); + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + return $this->payload->comment->html_url; + } +} diff --git a/app/Analyzers/GitHub/Events/CreateEvent.php b/app/Analyzers/GitHub/Events/CreateEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/CreateEvent.php @@ -0,0 +1,77 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * CreateEvent payload analyzer + * + * We don't support the repository ref type, as, according the documentation, + * "webhooks will not receive this event for created repositories".webhooks + * + * Another case when we won't receive the event is when at least four tags are + * pushed at once. + * + * @link https://developer.github.com/v3/activity/events/types/#createevent + */ +class CreateEvent extends Event { + + use WithRef; + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + $repository = $this->payload->repository->full_name; + $type = $this->payload->ref_type; + $ref = $this->payload->ref; + + if (!self::isValidRefType($type)) { + return trans( + 'GitHub.EventsDescriptions.CreateEventUnknown', + [ + 'type' => $type, + 'ref' => $ref, + ] + ); + } + + return trans( + 'GitHub.EventsDescriptions.CreateEvent', + [ + 'type' => $type, + 'ref' => $ref, + 'repository' => $repository, + ] + ); + } + + /** + * Gets link segments for the type + * + * @return Array + */ + private function getLinkRefSegments () { + return [ + 'tag' => '/releases/tag/', + 'branch' => '/tree/', + ]; + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + $type = $this->payload->ref_type; + $ref = $this->payload->ref; + + $url = $this->payload->repository->html_url; + $url .= $this->getLinkRefSegment($type); + $url .= $ref; + + return $url; + } +} diff --git a/app/Analyzers/GitHub/Events/DeleteEvent.php b/app/Analyzers/GitHub/Events/DeleteEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/DeleteEvent.php @@ -0,0 +1,73 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * DeleteEvent payload analyzer + * + * Another case when we won't receive the event is when at least four tags are + * deleted at once. + * + * @link https://developer.github.com/v3/activity/events/types/#deleteevent + */ +class DeleteEvent extends Event { + + use WithRef; + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + $repository = $this->payload->repository->full_name; + $type = $this->payload->ref_type; + $ref = $this->payload->ref; + + if (!self::isValidRefType($type)) { + return trans( + 'GitHub.EventsDescriptions.DeleteEventUnknown', + [ + 'type' => $type, + 'ref' => $ref, + ] + ); + } + + return trans( + 'GitHub.EventsDescriptions.DeleteEvent', + [ + 'type' => $type, + 'ref' => $ref, + 'repository' => $repository, + ] + ); + } + + /** + * Gets link segments for the type + * + * @return Array + */ + private function getLinkRefSegments () { + return [ + 'tag' => '/tags', + 'branch' => '/branches', + ]; + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + $type = $this->payload->ref_type; + $ref = $this->payload->ref; + + $url = $this->payload->repository->html_url; + $url .= $this->getLinkRefSegment($type); + + return $url; + } +} diff --git a/app/Analyzers/GitHub/Events/Event.php b/app/Analyzers/GitHub/Events/Event.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/Event.php @@ -0,0 +1,78 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +class Event { + + /// + /// Properties + /// + + /** + * The payload + * + * @var stdClass + */ + protected $payload; + + /// + /// Constructor + /// + + public function __construct ($payload) { + $this->payload = $payload; + } + + /// + /// Gets or initialize relevant class + /// + + /** + * Gets class name from the GitHub webhooks event name + * + * @param string $eventName The event name (e.g. commit_comment) + * @return string The event class name (e.g. CommitCommentEvent) + */ + public static function getClass ($eventName) { + return __NAMESPACE__ . '\\' . studly_case($eventName) . 'Event'; + } + + /** + * Gets an instance of the event class, from the + * + * @param string $eventName The event name (e.g. commit_comment) + * @return Event + */ + public static function forPayload ($eventName, $payload) { + $class = self::getClass($eventName); + if (!class_exists($class)) { + throw new \InvalidArgumentException("Class doesn't exist: $class (for $eventName)"); + } + return new $class($payload); + } + + /// + /// Helper methods + /// + + /** + * Cuts a text + * + * @param string $text The text to cut + * @param int $strLen The amount of characters to allow [optional] + * @param string $symbol The symbol to append to a cut text [optional] + */ + public static function cut ($text, $strLen = 114, $symbol = '…') { + $len = strlen($text); + if ($len <= $strLen) { + return $text; + } + + if ($strLen < 1) { + return $symbol; + } + + return substr($text, 0, $strLen - 1) . $symbol; + } + +} \ No newline at end of file diff --git a/app/Analyzers/GitHub/Events/PingEvent.php b/app/Analyzers/GitHub/Events/PingEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/PingEvent.php @@ -0,0 +1,35 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * PingEvent payload analyzer + * + * @link https://developer.github.com/webhooks/#ping-event + */ +class PingEvent extends Event { + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + return trans( + 'GitHub.EventsDescriptions.PingEvent', + [ + 'zen' => $this->payload->zen, + 'hook_id' => $this->payload->hook_id, + ] + ); + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + return ''; + } +} diff --git a/app/Analyzers/GitHub/Events/PushEvent.php b/app/Analyzers/GitHub/Events/PushEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/PushEvent.php @@ -0,0 +1,67 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * PushEvent payload analyzer + * + * @link https://developer.github.com/v3/activity/events/types/#pushevent + */ +class PushEvent extends Event { + + use WithCommit; + use WithRepoAndBranch; + + /** + * Gets the description message key according the amount of commits + * + * @param int $count The count of commits + * @return The l10n message key for description + */ + private static function getDescriptionMessageKey ($count) { + $key = 'GitHub.EventsDescriptions.PushEvent.'; + + if ($count === 0) { + return $key . '.0'; + } + + return $key . '.n'; + } + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + $n = count($this->payload->commits); + + if ($n === 1) { + // If only one commit is pushed at the time, + // we want a description for this commit. + return $this->getHeadCommitDescription(); + } + + // Otherwise, we want a description for the push. + return trans(self::getDescriptionMessageKey($n), [ + 'user' => $this->payload->pusher->name, + 'count' => $n, + 'repoAndBranch' => $this->getWhere(), + ]); + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + $n = count($this->payload->commits); + + if ($n === 1) { + return $this->payload->head_commit->url; + } + + return $this->payload->compare; + } +} diff --git a/app/Analyzers/GitHub/Events/RepositoryEvent.php b/app/Analyzers/GitHub/Events/RepositoryEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/RepositoryEvent.php @@ -0,0 +1,42 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * RepositoryEvent payload analyzer + * + * @link https://developer.github.com/v3/activity/events/types/#repositoryevent + */ +class RepositoryEvent extends Event { + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + $message = trans('GitHub.EventsDescriptions.RepositoryEvent', [ + 'repository' => $this->payload->repository->full_name, + ]); + + if ($this->payload->repository->fork) { + $message .= trans('GitHub.EventsDescriptions.RepositoryEventFork'); + } + + if ($description = $this->payload->repository->description) { + $message .= trans('GitHub.Separator'); + $message .= $description; + } + + return $message; + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + return $this->payload->repository->html_url; + } +} diff --git a/app/Analyzers/GitHub/Events/StatusEvent.php b/app/Analyzers/GitHub/Events/StatusEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/StatusEvent.php @@ -0,0 +1,74 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * StatusEvent payload analyzer + * + * @link https://developer.github.com/v3/activity/events/types/#statusevent + */ +class StatusEvent extends Event { + + /** + * Gets state localized message + * + * @return string + */ + private function getState () { + $state = $this->payload->state; // pending, success, failure, or error + $key = 'GitHub.StatusEventState.' . $state; + return trans($key); + } + + /** + * Gets status result + * + * @return string + */ + private function getStatusResult () { + $glue = trans('GitHub.Separator'); + $fragments = array_filter([ + $this->payload->context, + $this->payload->description, + $this->getState(), + ]); + + return implode($glue, $fragments); + } + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + $glue = trans('GitHub.Separator'); + $fragments = array_filter([ + $this->payload->context, + $this->payload->description, + $this->getState(), + ]); + + $description = implode($glue, $fragments); + + return trans('GitHub.EventsDescriptions.StatusEvent', [ + 'commit' => substr($this->payload->sha, 0, 8), + 'status' => $this->getStatusResult(), + ]); + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + $url = $this->payload->target_url; + + if ($url === null) { + return ""; + } + + return $url; + } +} diff --git a/app/Analyzers/GitHub/Events/UnknownEvent.php b/app/Analyzers/GitHub/Events/UnknownEvent.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/UnknownEvent.php @@ -0,0 +1,42 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * Unknown event payload analyzer + */ +class UnknownEvent extends Event { + + /** + * @var string + */ + private $eventType; + + /** + * Initializes a new instance of the UnknownEvent class, an Event analyzer + * class to handle unknown events type. + * + * @param string $eventType The event type (e.g. push) + */ + public function __construct ($eventType) { + $this->eventType = $eventType; + } + + /** + * Gets description for the payload + * + * @return string + */ + public function getDescription () { + return "Some $this->eventType happened"; + } + + /** + * Gets link for the payload + * + * @return string + */ + public function getLink () { + return ""; + } +} diff --git a/app/Analyzers/GitHub/Events/WithCommit.php b/app/Analyzers/GitHub/Events/WithCommit.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/WithCommit.php @@ -0,0 +1,64 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * Helper methods for events with a need to specify commit information + * (e.g. push) + * + * @link https://developer.github.com/v3/activity/events/types/#pushevent + */ +trait WithCommit { + + /** + * Gets the title of the head commit + * + * @return string + */ + private function getHeadCommitTitle () { + return static::getCommitTitle($this->payload->head_commit->message); + } + + /** + * Extracts the commit title from the whole commit message. + * + * @param string $message The commit message + * @return string The commit title + */ + public static function getCommitTitle ($message) { + // Discards extra lines + $pos = strpos($message, "\n"); + if ($pos > 0) { + $message = substr($message, 0, $pos); + } + + // Short messages are returned as is + // Longer messages are truncated + return self::cut($message, 72); + } + + /** + * Gets the description text for the head commit. + * + * @return string + */ + private function getHeadCommitDescription () { + $commit = $this->payload->head_commit; + $committer = $commit->committer->username; + $author = $commit->author->username; + + $message = trans('GitHub.Commits.Message', [ + 'committer' => $committer, + 'title' => $this->getHeadCommitTitle(), + ]); + + if ($committer !== $author) { + $message .= trans('GitHub.Commits.Authored', [ + 'author' => $author, + ]); + } + + return $message; + } + +} diff --git a/app/Analyzers/GitHub/Events/WithRef.php b/app/Analyzers/GitHub/Events/WithRef.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/WithRef.php @@ -0,0 +1,43 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * References helper methods for events using ref and ref_type fields. + * (e.g. create and delete) + * + * @link https://developer.github.com/v3/activity/events/types/#createevent + * @link https://developer.github.com/v3/activity/events/types/#deleteevent + */ +trait WithRef { + + /** + * Determines if the ref type is valid. + * + * The ref type 'repository' is deemed invalid, as we shouldn't receive it. + * + * @param string $type The ref type to check + * @return bool true if the ref type id valid; otheriwse, false + */ + protected static function isValidRefType ($type) { + $types = ['branch', 'tag']; + return in_array($type, $types); + } + + /** + * Gets link ref segment for the payload + * + * @param string $type The reference type + * @return string the part of the URL for this reference type (e.g. /tree/) + */ + protected function getLinkRefSegment ($type) { + $segments = $this->getLinkRefSegments(); + + if (!array_key_exists($type, $segments)) { + throw new \InvalidArgumentException; + } + + return $segments[$type]; + } + +} diff --git a/app/Analyzers/GitHub/Events/WithRepoAndBranch.php b/app/Analyzers/GitHub/Events/WithRepoAndBranch.php new file mode 100644 --- /dev/null +++ b/app/Analyzers/GitHub/Events/WithRepoAndBranch.php @@ -0,0 +1,51 @@ +<?php + +namespace Nasqueron\Notifications\Analyzers\GitHub\Events; + +/** + * Helper methods for events with a need to specify the repo and the branch + * (e.g. push) + * + * @link https://developer.github.com/v3/activity/events/types/#pushevent + */ +trait WithRepoAndBranch { + + /** + * Gets repository and branch information + * + * @return string + */ + public function getWhere () { + $repo = $this->payload->repository->name; + $branch = $this->payload->ref; + + return static::getRepositoryAndBranch($repo, $branch); + } + + /** + * Gets a repository and branch information string + * + * @param string $repo The repository + * @param string $branch The branch + * @return string "<repo>" or "<repo> (branch <branch>)" when branch isn't master + */ + public static function getRepositoryAndBranch ($repo = "", $branch = "") { + if ($repo === "") { + return ""; + } + + if (starts_with($branch, "refs/heads/")) { + $branch = substr($branch, 11); + } + + if ($branch === "" || $branch === "master") { + return $repo; + } + + return trans('GitHub.RepoAndBranch', [ + 'repo' => $repo, + 'branch' => $branch, + ]); + } + +} diff --git a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php --- a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php +++ b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php @@ -2,6 +2,9 @@ namespace Nasqueron\Notifications\Analyzers\GitHub; +use Nasqueron\Notifications\Analyzers\GitHub\Events\Event; +use Nasqueron\Notifications\Analyzers\GitHub\Events\UnknownEvent; + use Config; use Storage; @@ -28,13 +31,19 @@ */ private $payload; - /** * The configuration for the payload analyzer - * @var GitHubPayloadAnalyzerConfiguration; + * @var Event; */ private $configuration; + /** + * The payload analyzer event + * + * @var Nasqueron\Notifications\Analyzers\GitHub\Events\Event; + */ + private $analyzerEvent; + /// /// Constructor /// @@ -56,6 +65,12 @@ $this->payload = $payload; $this->loadConfiguration($project); + + try { + $this->analyzerEvent = Event::forPayload($event, $payload); + } catch (\InvalidArgumentException $ex) { + $this->analyzerEvent = new UnknownEvent($event); + } } /// @@ -142,146 +157,12 @@ /// /** - * Gets repository and branch information - * - * @return string - */ - public function getWhere () { - $repo = $this->payload->repository->name; - $branch = $this->payload->ref; - return static::getRepositoryAndBranch($repo, $branch); - } - - /** - * Gets a repository and branch information string - * - * @param string $repo The repository - * @param string $branch The branch - * @return string "<repo>" or "<repo> (branch <branch>)" when branch isn't master - */ - public static function getRepositoryAndBranch ($repo = "", $branch = "") { - if ($repo === "") { - return ""; - } - - if (starts_with($branch, "refs/heads/")) { - $branch = substr($branch, 11); - } - - if ($branch === "" || $branch === "master") { - return $repo; - } - - return "$repo (branch $branch)"; - } - - /** - * Gets the title of the head commit - * - * @return string - */ - private function getHeadCommitTitle () { - return static::getCommitTitle($this->payload->head_commit->message); - } - - /** - * Extracts the commit title from the whole commit message. - * - * @param string $message The commit message - * @return string The commit title - */ - public static function getCommitTitle ($message) { - // Discards extra lines - $pos = strpos($message, "\n"); - if ($pos > 0) { - $message = substr($message, 0, $pos); - } - - // Short messages are returned as is - $len = strlen($message); - if ($len <= 72) { - return $message; - } - - // Longer messages are truncated - return substr($message, 0, 71) . '…'; - } - - /** - * Gets the description text for the head commit. - * - * @return string - */ - private function getHeadCommitDescription () { - $commit = $this->payload->head_commit; - $title = $this->getHeadCommitTitle(); - $committer = $commit->committer->username; - $author = $commit->author->username; - - $message = "$committer committed $title"; - if ($committer !== $author) { - $message .= " (authored by $author)"; - } - - return $message; - } - - /** * Gets a short textual description of the event * * @return string */ public function getDescription () { - switch ($this->event) { - case "create": - $repository = $this->payload->repository->full_name; - $type = $this->payload->ref_type; - $ref = $this->payload->ref; - - if ($type === "tag" || $type === "branch") { - return "New $type on $repository: $ref"; - } - - return "Unknown create: $type $ref"; - - case "ping": - $quote = $this->payload->zen; - return "« $quote » — GitHub Webhooks ping zen aphorism."; - - case "push": - $n = count($this->payload->commits); - if ($n === 1) { - return $this->getHeadCommitDescription(); - } - - $repoAndBranch = $this->getWhere(); - $user = $this->payload->pusher->name; - - if ($n === 0) { - return "$user forcely updated $repoAndBranch"; - } - - return "$user pushed $n commits to $repoAndBranch"; - - case "repository": - $repository = $this->payload->repository->full_name; - $message = "New repository $repository"; - if ($this->payload->repository->fork) { - $message .= " (fork)"; - } - if ($description = $this->payload->repository->description) { - $message .= " — $description"; - } - return $message; - - case "status": - return $this->payload->description - . " — " - . $this->payload->context; - - default: - return "Some $this->event happened"; - } + return $this->analyzerEvent->getDescription(); } /** @@ -290,35 +171,6 @@ * @return string The most relevant URL */ public function getLink () { - switch ($this->event) { - case "create": - $type = $this->payload->ref_type; - $ref = $this->payload->ref; - $url = $this->payload->repository->html_url; - - if ($type === "tag") { - $url .= "/releases/tag/" . $ref; - } elseif ($type === "branch") { - $url .= "/tree/" . $ref; - } - - return $url; - - case "push": - $n = count($this->payload->commits); - if ($n === 1) { - return $this->payload->head_commit->url; - } - return $this->payload->compare; - - case "repository": - return $this->payload->repository->html_url; - - case "status": - return $this->payload->target_url; - - default: - return ""; - } + return $this->analyzerEvent->getLink(); } } diff --git a/resources/lang/en/GitHub.php b/resources/lang/en/GitHub.php new file mode 100644 --- /dev/null +++ b/resources/lang/en/GitHub.php @@ -0,0 +1,53 @@ +<?php + +return [ + + /* + |-------------------------------------------------------------------------- + | GitHub notifications messages + |-------------------------------------------------------------------------- + | + | The following language lines are used to localize notifications for events + | fired by GitHub + | + */ + + 'Separator' => ' — ', + + 'Commits' => [ + 'Message' => ':committer committed :title', + 'Authored' => ' (authored by :author)', // appended to Message + ], + + 'RepoAndBranch' => ':repo (branch :branch)', + + 'EventsDescriptions' => [ + 'CommitCommentEvent' => ':author added a comment to :commit: :excerpt', + + 'CreateEvent' => 'New :type on :repository: :ref', + 'CreateEventUnknown' => 'Unknown create reference: :type :ref', + + 'DeleteEvent' => 'Removed :type on :repository: :ref', + 'DeleteEventUnknown' => 'Unknown delete reference: :type :ref', + + 'PingEvent' => '« :zen » — GitHub Webhooks ping zen aphorism.', + + 'PushEvent' => [ + '0' => ':user forcely updated :repoAndBranch', + 'n' => ':user pushed :count commits to :repoAndBranch', // n > 1 + ], + + 'RepositoryEvent' => 'New repository :repository', + 'RepositoryEventFork' => ' (fork)', + + 'StatusEvent' => 'Status of :commit: :status', + ], + + 'StatusEventState' => [ + 'pending' => 'pending', + 'success' => 'success', + 'failure' => 'failure', + 'error' => 'error', + ], + +]; diff --git a/tests/Analyzers/GitHub/Events/CreateEventTest.php b/tests/Analyzers/GitHub/Events/CreateEventTest.php new file mode 100644 --- /dev/null +++ b/tests/Analyzers/GitHub/Events/CreateEventTest.php @@ -0,0 +1,41 @@ +<?php + +namespace Nasqueron\Notifications\Tests\Analyzers\GitHub\Events; + +use Nasqueron\Notifications\Analyzers\GitHub\Events\CreateEvent; +use Nasqueron\Notifications\Tests\TestCase; + +class CreateEventTest extends TestCase { + /** + * @var CreateEvent + */ + private $event; + + public function setUp () { + $payload = new \stdClass; + $payload->repository = new \stdClass; + $payload->repository->full_name = 'baxterthehacker/public-repo'; + $payload->repository->html_url = 'https://github.com/baxterthehacker/public-repo'; + $payload->ref_type = 'bookmark'; + $payload->ref = 'quux'; + + $this->event = new CreateEvent($payload); + + parent::setUp(); + } + + public function testNonExistingRefType () { + $this->assertSame( + "Unknown create reference: bookmark quux", + $this->event->getDescription() + ); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testNonExistingRefTypeLinkException () { + $this->event->getLink(); + } + +} diff --git a/tests/Analyzers/GitHub/Events/EventTest.php b/tests/Analyzers/GitHub/Events/EventTest.php new file mode 100644 --- /dev/null +++ b/tests/Analyzers/GitHub/Events/EventTest.php @@ -0,0 +1,89 @@ +<?php + +namespace Nasqueron\Notifications\Tests\Analyzers\GitHub\Events; + +use Nasqueron\Notifications\Analyzers\GitHub\Events\Event; +use Nasqueron\Notifications\Tests\TestCase; + +class EventTest extends TestCase { + + public function testGetClass () { + $this->assertSame( + 'Nasqueron\Notifications\Analyzers\GitHub\Events\CommitCommentEvent', + Event::getClass('commit_comment') + ); + } + + public function testForPayload () { + $this->assertInstanceOf( + 'Nasqueron\Notifications\Analyzers\GitHub\Events\CommitCommentEvent', + Event::forPayload('commit_comment', new \stdClass) + ); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testForPayloadWithException () { + Event::forPayload('not_existing', new \stdClass); + } + + public function testCut () { + $this->assertSame('', Event::cut('')); + $this->assertSame('', Event::cut('', 0)); + $this->assertSame('…', Event::cut('Lorem ipsum dolor', 0)); + $this->assertSame('Lorem…', Event::cut('Lorem ipsum dolor', 6)); + $this->assertSame('Lorem ipsum dolor', Event::cut('Lorem ipsum dolor')); + } + + /** + * @dataProvider payloadDescriptionProvider + */ + public function testGetDescriptionAndLink ($eventName, + $expectedDescription, + $expectedLink) { + $filename = __DIR__ . "/../../../data/payloads/GitHubEvents/$eventName.json"; + $payload = json_decode(file_get_contents($filename)); + $event = Event::forPayload($eventName, $payload); + + $this->assertSame($expectedDescription, $event->getDescription()); + $this->assertSame($expectedLink, $event->getLink()); + } + + public function payloadDescriptionProvider () { + return [ + 'CommitCommentEvent' => [ + 'commit_comment', + 'baxterthehacker added a comment to 9049f126: This is a really good change! :+1:', + 'https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394' + ], + 'CreateEvent' => [ + 'create', + 'New tag on baxterthehacker/public-repo: 0.0.1', + 'https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1' + ], + 'DeleteEvent' => [ + 'delete', + 'Removed tag on baxterthehacker/public-repo: simple-tag', + 'https://github.com/baxterthehacker/public-repo/tags' + ], + 'PushEvent' => [ + 'push', + 'baxterthehacker committed Update README.md', + 'https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c' + ], + 'RepositoryEvent' => [ + 'repository', + 'New repository baxterandthehackers/new-repository', + 'https://github.com/baxterandthehackers/new-repository' + ], + 'StatusEvent' => [ + 'status', + 'Status of 9049f126: default — success', + '' + ], + + ]; + } + +} diff --git a/tests/Analyzers/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHubPayloadAnalyzerTest.php --- a/tests/Analyzers/GitHubPayloadAnalyzerTest.php +++ b/tests/Analyzers/GitHubPayloadAnalyzerTest.php @@ -4,6 +4,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; +use Nasqueron\Notifications\Analyzers\GitHub\Events\PushEvent; use Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer; use Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzerConfiguration; use Nasqueron\Notifications\Tests\TestCase; @@ -27,6 +28,8 @@ json_decode(file_get_contents($filename)), new GitHubPayloadAnalyzerConfiguration() ); + + parent::setUp(); } /** @@ -45,8 +48,8 @@ } public function testGetCommitTitle () { - $this->assertEquals("", GitHubPayloadAnalyzer::getCommitTitle("")); - $this->assertEquals("Lorem ipsum dolor", GitHubPayloadAnalyzer::getCommitTitle("Lorem ipsum dolor")); + $this->assertEquals("", PushEvent::getCommitTitle("")); + $this->assertEquals("Lorem ipsum dolor", PushEvent::getCommitTitle("Lorem ipsum dolor")); $longCommitMessages = [ "I was born in a water moon. Some people, especially its inhabitants, called it a planet, but as it was only a little over two hundred kilometres in diameter, 'moon' seems the more accurate term. The moon was made entirely of water, by which I mean it was a globe that not only had no land, but no rock either, a sphere with no solid core at all, just liquid water, all the way down to the very centre of the globe.", @@ -56,21 +59,21 @@ foreach ($longCommitMessages as $longCommitMessage) { $this->assertEquals( $shortCommitTitle, - GitHubPayloadAnalyzer::getCommitTitle($longCommitMessage) + PushEvent::getCommitTitle($longCommitMessage) ); } } public function testGetRepositoryAndBranch () { - $this->assertEquals("", GitHubPayloadAnalyzer::getRepositoryAndBranch("", "master")); - $this->assertEquals("", GitHubPayloadAnalyzer::getRepositoryAndBranch("", "foo")); - $this->assertEquals("quux", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "master")); - $this->assertEquals("quux", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "refs/heads/master")); - $this->assertEquals("quux", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "")); - $this->assertEquals("quux (branch foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "refs/heads/foo")); - $this->assertEquals("quux (branch feature/foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "refs/heads/feature/foo")); - $this->assertEquals("quux (branch feature/foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "feature/foo")); - $this->assertEquals("quux (branch foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "foo")); - $this->assertEquals("quux (branch 0)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "0")); + $this->assertEquals("", PushEvent::getRepositoryAndBranch("", "master")); + $this->assertEquals("", PushEvent::getRepositoryAndBranch("", "foo")); + $this->assertEquals("quux", PushEvent::getRepositoryAndBranch("quux", "master")); + $this->assertEquals("quux", PushEvent::getRepositoryAndBranch("quux", "refs/heads/master")); + $this->assertEquals("quux", PushEvent::getRepositoryAndBranch("quux", "")); + $this->assertEquals("quux (branch foo)", PushEvent::getRepositoryAndBranch("quux", "refs/heads/foo")); + $this->assertEquals("quux (branch feature/foo)", PushEvent::getRepositoryAndBranch("quux", "refs/heads/feature/foo")); + $this->assertEquals("quux (branch feature/foo)", PushEvent::getRepositoryAndBranch("quux", "feature/foo")); + $this->assertEquals("quux (branch foo)", PushEvent::getRepositoryAndBranch("quux", "foo")); + $this->assertEquals("quux (branch 0)", PushEvent::getRepositoryAndBranch("quux", "0")); } } diff --git a/tests/data/payloads/GitHubEvents/commit_comment.json b/tests/data/payloads/GitHubEvents/commit_comment.json new file mode 100644 --- /dev/null +++ b/tests/data/payloads/GitHubEvents/commit_comment.json @@ -0,0 +1,140 @@ +{ + "action": "created", + "comment": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394", + "id": 11056394, + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "position": null, + "line": null, + "path": null, + "commit_id": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "created_at": "2015-05-05T23:40:29Z", + "updated_at": "2015-05-05T23:40:29Z", + "body": "This is a really good change! :+1:" + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/tests/data/payloads/GitHubEvents/create.json b/tests/data/payloads/GitHubEvents/create.json new file mode 100644 --- /dev/null +++ b/tests/data/payloads/GitHubEvents/create.json @@ -0,0 +1,113 @@ +{ + "ref": "0.0.1", + "ref_type": "tag", + "master_branch": "master", + "description": "", + "pusher_type": "user", + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:38Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/tests/data/payloads/GitHubEvents/delete.json b/tests/data/payloads/GitHubEvents/delete.json new file mode 100644 --- /dev/null +++ b/tests/data/payloads/GitHubEvents/delete.json @@ -0,0 +1,111 @@ +{ + "ref": "simple-tag", + "ref_type": "tag", + "pusher_type": "user", + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:40Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/tests/data/payloads/GitHubEvents/push.json b/tests/data/payloads/GitHubEvents/push.json new file mode 100644 --- /dev/null +++ b/tests/data/payloads/GitHubEvents/push.json @@ -0,0 +1,161 @@ +{ + "ref": "refs/heads/changes", + "before": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "created": false, + "deleted": false, + "forced": false, + "base_ref": null, + "compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f", + "commits": [ + { + "id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "distinct": true, + "message": "Update README.md", + "timestamp": "2015-05-05T19:40:15-04:00", + "url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "added": [ + + ], + "removed": [ + + ], + "modified": [ + "README.md" + ] + } + ], + "head_commit": { + "id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "distinct": true, + "message": "Update README.md", + "timestamp": "2015-05-05T19:40:15-04:00", + "url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "added": [ + + ], + "removed": [ + + ], + "modified": [ + "README.md" + ] + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com" + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://github.com/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": 1430869212, + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": 1430869217, + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "stargazers": 0, + "master_branch": "master" + }, + "pusher": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/tests/data/payloads/GitHubEvents/repository.json b/tests/data/payloads/GitHubEvents/repository.json new file mode 100644 --- /dev/null +++ b/tests/data/payloads/GitHubEvents/repository.json @@ -0,0 +1,119 @@ +{ + "action": "created", + "repository": { + "id": 27496774, + "name": "new-repository", + "full_name": "baxterandthehackers/new-repository", + "owner": { + "login": "baxterandthehackers", + "id": 7649605, + "avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterandthehackers", + "html_url": "https://github.com/baxterandthehackers", + "followers_url": "https://api.github.com/users/baxterandthehackers/followers", + "following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions", + "organizations_url": "https://api.github.com/users/baxterandthehackers/orgs", + "repos_url": "https://api.github.com/users/baxterandthehackers/repos", + "events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterandthehackers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": true, + "html_url": "https://github.com/baxterandthehackers/new-repository", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterandthehackers/new-repository", + "forks_url": "https://api.github.com/repos/baxterandthehackers/new-repository/forks", + "keys_url": "https://api.github.com/repos/baxterandthehackers/new-repository/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterandthehackers/new-repository/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterandthehackers/new-repository/teams", + "hooks_url": "https://api.github.com/repos/baxterandthehackers/new-repository/hooks", + "issue_events_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterandthehackers/new-repository/events", + "assignees_url": "https://api.github.com/repos/baxterandthehackers/new-repository/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterandthehackers/new-repository/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterandthehackers/new-repository/tags", + "blobs_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterandthehackers/new-repository/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterandthehackers/new-repository/languages", + "stargazers_url": "https://api.github.com/repos/baxterandthehackers/new-repository/stargazers", + "contributors_url": "https://api.github.com/repos/baxterandthehackers/new-repository/contributors", + "subscribers_url": "https://api.github.com/repos/baxterandthehackers/new-repository/subscribers", + "subscription_url": "https://api.github.com/repos/baxterandthehackers/new-repository/subscription", + "commits_url": "https://api.github.com/repos/baxterandthehackers/new-repository/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterandthehackers/new-repository/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues/comments/{number}", + "contents_url": "https://api.github.com/repos/baxterandthehackers/new-repository/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterandthehackers/new-repository/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterandthehackers/new-repository/merges", + "archive_url": "https://api.github.com/repos/baxterandthehackers/new-repository/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterandthehackers/new-repository/downloads", + "issues_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterandthehackers/new-repository/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterandthehackers/new-repository/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterandthehackers/new-repository/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterandthehackers/new-repository/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterandthehackers/new-repository/releases{/id}", + "created_at": "2014-12-03T16:39:25Z", + "updated_at": "2014-12-03T16:39:25Z", + "pushed_at": "2014-12-03T16:39:25Z", + "git_url": "git://github.com/baxterandthehackers/new-repository.git", + "ssh_url": "git@github.com:baxterandthehackers/new-repository.git", + "clone_url": "https://github.com/baxterandthehackers/new-repository.git", + "svn_url": "https://github.com/baxterandthehackers/new-repository", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "organization": { + "login": "baxterandthehackers", + "id": 7649605, + "url": "https://api.github.com/orgs/baxterandthehackers", + "repos_url": "https://api.github.com/orgs/baxterandthehackers/repos", + "events_url": "https://api.github.com/orgs/baxterandthehackers/events", + "members_url": "https://api.github.com/orgs/baxterandthehackers/members{/member}", + "public_members_url": "https://api.github.com/orgs/baxterandthehackers/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=2" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=2", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/tests/data/payloads/GitHubEvents/status.json b/tests/data/payloads/GitHubEvents/status.json new file mode 100644 --- /dev/null +++ b/tests/data/payloads/GitHubEvents/status.json @@ -0,0 +1,206 @@ +{ + "id": 214015194, + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "name": "baxterthehacker/public-repo", + "target_url": null, + "context": "default", + "description": null, + "state": "success", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "commit": { + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "message": "Initial commit", + "tree": { + "sha": "02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees/02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0" + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comment_count": 1 + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b/comments", + "author": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + + ] + }, + "branches": [ + { + "name": "master", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b" + } + }, + { + "name": "changes", + "commit": { + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + { + "name": "gh-pages", + "commit": { + "sha": "b11bb7545ac14abafc6191a0481b0d961e7793c6", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/b11bb7545ac14abafc6191a0481b0d961e7793c6" + } + } + ], + "created_at": "2015-05-05T23:40:39Z", + "updated_at": "2015-05-05T23:40:39Z", + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:39Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +}