The branch PHP_POST_RECEIVE on karma.git has been updated via a7fabb3c3cf3274a48efe8d7ae948af68984f0d1 (commit) from 4d61fb520544f543d8c6120fb02548de4bfc2f06 (commit)
http://git.php.net/?p=karma.git;a=log;h=a7fabb3c3cf3274a48efe8d7ae948af68984f0d1;hp=4d61fb520544f543d8c6120fb02548de4bfc2f06 Summary of changes: hooks/pre-receive | 1 + lib/Git/PostReceiveHook.php | 65 +++++++++++++++++++++++++++++++++++++++--- lib/Git/PreReceiveHook.php | 7 ++-- lib/Git/ReceiveHook.php | 3 +- 4 files changed, 66 insertions(+), 10 deletions(-) -- Log ---------------------------------------- commit a7fabb3c3cf3274a48efe8d7ae948af68984f0d1 Author: Alexander Moskaliov <ir...@php.net> Date: Mon Mar 12 20:27:48 2012 +0400 refactoring and add commets for branch and tag mail format diff --git a/hooks/pre-receive b/hooks/pre-receive index c0e838d..250b609 100755 --- a/hooks/pre-receive +++ b/hooks/pre-receive @@ -112,6 +112,7 @@ if ($hook->isKarmaIgnored()) { accept("No karma check necessary. Thank you for your contribution.\n"); } +$hook->hookInput(); $repo_name = $hook->getRepositoryName(); $pi = new \Git\PushInformation($hook); $req_paths = ($pi->isForced()) ? [''] : $hook->getReceivedPaths(); diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php index 1d5daee..821303a 100644 --- a/lib/Git/PostReceiveHook.php +++ b/lib/Git/PostReceiveHook.php @@ -8,8 +8,6 @@ class PostReceiveHook extends ReceiveHook private $mailingList = ''; private $emailPrefix = ''; - - private $refs = []; private $newBranches = []; private $updatedBranches = []; private $revisions = []; @@ -38,7 +36,7 @@ class PostReceiveHook extends ReceiveHook */ public function process() { - $this->refs = $this->hookInput(); + $this->hookInput(); //cache list of new and updated branches foreach ($this->refs as $ref) { @@ -70,6 +68,37 @@ class PostReceiveHook extends ReceiveHook } /** + * Send mail about branch. + * Subject: [git] [branch] %STATUS% branch %BRANCH_NAME% in %PROJECT% + * Body: + * Branch %BRANCH_NAME% in %PROJECT% was %STATUS% + * Date: Thu, 08 Mar 2012 12:39:48 +0000(current mail date) + * + * Link: http://git.php.net/?p=%PROJECT_PATH%;a=shortlog;h=refs/heads/%BRANCH_NAME% + * + * --part1-- + * Log: + * + * --per commit-- + * Commit: %SHA% + * Author: %USER% Thu, 08 Mar 2012 12:39:48 +0000 + * Committer: %USER% Thu, 08 Mar 2012 12:39:48 +0000 + * Link: http://git.php.net/?p=%PROJECT_PATH%;a=commitdiff;h=%SHA% + * Shortlog: %SHORT_MESSAGE% + * --/per commit-- + * + * --/part1-- + * + * (if part1 exceeded maximum size) + * --part1-- + * Commits: + * + * --per commit-- + * Commit: %SHA% + * --/per commit-- + * + * --/part1-- + * * @param $name string * @param $changeType int * @param $oldrev string @@ -77,6 +106,7 @@ class PostReceiveHook extends ReceiveHook */ private function sendBranchMail($name, $changeType, $oldrev, $newrev) { + // FIXME: work in progress if ($changeType == self::TYPE_UPDATED) { $title = "Branch " . $name . " was updated"; @@ -146,6 +176,31 @@ class PostReceiveHook extends ReceiveHook /** + * Send mail about tag. + * Subject: [git] [tag] %STATUS% tag %TAGNAME% in %PROJECT% + * Body: + * Tag %TAGNAME% in %PROJECT% was %STATUS% (if sha was changed)from %OLD_SHA% + * Tag(if annotaded): %SHA% + * Tagger(if annotaded): %USER% Thu, 08 Mar 2012 12:39:48 +0000 + * + * Link: http://git.php.net/?p=%PROJECT_PATH%;a=tag;h=%SHA% + * + * Log(if annotaded): + * %MESSAGE% + * + * Target: %SHA% + * Author: %USER% Thu, 08 Mar 2012 12:39:48 +0000 + * Committer: %USER% Thu, 08 Mar 2012 12:39:48 +0000 + * Parents: %SHA_PARENTS% + * Target link: http://git.php.net/?p=%PROJECT_PATH%;a=commitdiff;h=%SHA% + * Target log: + * %MESSAGE% + * + * --part1-- + * Changed paths: + * %PATHS% + * --/part1-- + * * @param $name string * @param $changetype int * @param $oldrev string @@ -153,7 +208,7 @@ class PostReceiveHook extends ReceiveHook */ private function sendTagMail($name, $changetype, $oldrev, $newrev) { - + // FIXME: work in progress if ($changetype == self::TYPE_UPDATED) { $title = "Tag " . $name . " was updated"; } elseif ($changetype == self::TYPE_CREATED) { @@ -262,7 +317,7 @@ class PostReceiveHook extends ReceiveHook * Committer: %USER% Thu, 08 Mar 2012 12:39:48 +0000 * Parents: %SHA_PARENTS% * - * Commit: http://git.php.net/?p=%PROJECT_PATH%;a=commitdiff;h=%SHA% + * Link: http://git.php.net/?p=%PROJECT_PATH%;a=commitdiff;h=%SHA% * * Log: * %MESSAGE% diff --git a/lib/Git/PreReceiveHook.php b/lib/Git/PreReceiveHook.php index 2e93012..1318890 100644 --- a/lib/Git/PreReceiveHook.php +++ b/lib/Git/PreReceiveHook.php @@ -24,7 +24,7 @@ class PreReceiveHook extends ReceiveHook public function mapInput(callable $fn) { $result = []; - foreach($this->hookInput() as $input) { + foreach($this->refs as $input) { $result[] = $fn($input['old'], $input['new']); } @@ -45,8 +45,6 @@ class PreReceiveHook extends ReceiveHook public function getReceivedPaths() { - $parsed_input = $this->hookInput(); - // escaped branches $allBranches =$this->escapeArrayShellArgs($this->getAllBranches()); @@ -65,7 +63,8 @@ class PreReceiveHook extends ReceiveHook return array_keys($paths); }, - $parsed_input); + $this->refs + ); /* flattern the array */ $paths = array_reduce($paths, 'array_merge', []); diff --git a/lib/Git/ReceiveHook.php b/lib/Git/ReceiveHook.php index 650a855..ea4d6bd 100644 --- a/lib/Git/ReceiveHook.php +++ b/lib/Git/ReceiveHook.php @@ -13,6 +13,7 @@ abstract class ReceiveHook const REF_TAG = 1; private $repositoryName = ''; + protected $refs = []; public function __construct($basePath) { @@ -135,6 +136,6 @@ abstract class ReceiveHook $parsed_input[$ref['refname']] = $ref; } } - return $parsed_input; + $this->refs = $parsed_input; } } Thank you for your contribution. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php