Page MenuHomeDevCentral

D128.id312.diff
No OneTemporary

D128.id312.diff

diff --git a/app/Analyzers/PhabricatorPayloadAnalyzer.php b/app/Analyzers/PhabricatorPayloadAnalyzer.php
--- a/app/Analyzers/PhabricatorPayloadAnalyzer.php
+++ b/app/Analyzers/PhabricatorPayloadAnalyzer.php
@@ -119,175 +119,4 @@
return $this->configuration->defaultGroup;
}
- ///
- /// Description of the payload
- ///
-
- /**
- * 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;
- 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;
-
- default:
- return "Some $this->event happened";
- }
- }
-
- /**
- * Gets a link to view the event on GitHub
- *
- * @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;
-
- default:
- return "";
- }
- }
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 20:29 (21 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2247504
Default Alt Text
D128.id312.diff (5 KB)

Event Timeline