[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php lib/Git/ReceiveHook.php

2012-03-20 Thread Alexander Moskaliov
Commit: 42d233ae4752adbce2709553cef0cd456b92a2e0
Author: Alexander Moskaliov(ir...@php.net) Tue, 20 Mar 2012 10:34:35 
+0400
Committer: Alexander Moskaliov(ir...@php.net)  Tue, 20 Mar 2012 10:35:41 
+0400
Parents: c3c822e0f983c7514f8043ec11ceeef9c80100c0 
4a6cbdd7b551664f76c536fd67c009ba25c98d2d

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=42d233ae4752adbce2709553cef0cd456b92a2e0

Log:
Merge branch 'PHP_POST_RECEIVE'

Changed paths:
  MM  lib/Git/PostReceiveHook.php
  MM  lib/Git/ReceiveHook.php

42d233ae4752adbce2709553cef0cd456b92a2e0
diff --combined lib/Git/PostReceiveHook.php
index 633ff77,743b6ac..bd3be9b
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@@ -17,12 -17,14 +17,14 @@@ class PostReceiveHook extends ReceiveHo
  
  private $allBranches = [];
  
+ private $branchesMailIds = [];
+ 
  /**
-  * @param $basePath string base path for all repositories
-  * @param $pushAuthor string user who make push
-  * @param $usersFile string path to file with users data
-  * @param $mailingList string mail recipient
-  * @param $emailPrefix string prefix for mail subject
+  * @param string $basePath base path for all repositories
+  * @param string $pushAuthor user who make push
+  * @param string $usersFile path to file with users data
+  * @param string $mailingList mail recipient
+  * @param string $emailPrefix prefix for mail subject
   */
  public function __construct($basePath, $pushAuthor, $usersFile, 
$mailingList, $emailPrefix)
  {
@@@ -37,73 -39,9 +39,73 @@@
  $this-allBranches = $this-getAllBranches();
  }
  
 +
 +public function getReceivedMessages()
 +{
 +$this-hookInput();
 +
 +$paths = array_map(
 +function ($input) {
 +return $this-getReceivedMessagesForRange($input['old'], 
$input['new']);
 +},
 +$this-refs);
 +
 +/* remove empty lines, and flattern the array */
 +$flattend = array_reduce($paths, 'array_merge', []);
 +$paths= array_filter($flattend);
 +
 +return array_unique($paths);
 +}
 +
 +/**
 + * Returns an array of commit messages between revision $old and $new.
 + *
 + * @param string $old The old revison number.
 + * @parma string $new The new revison umber.
 + *
 + * @return array
 + */
 +private function getReceivedMessagesForRange($old, $new)
 +{
 +$repourl = \Git::getRepositoryPath();
 +$output = [];
 +
 +if ($old == '') {
 +$cmd = sprintf(
 +%s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
 +self::GIT_EXECUTABLE,
 +$repourl
 +);
 +exec($cmd, $output);
 +
 +/* do we have heads? otherwise it's a new repo! */
 +$heads = implode(' ', $output);
 +$not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
 +$cmd   = sprintf(
 +'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s %s',
 +\Git::GIT_EXECUTABLE,
 +$repourl,
 +$not,
 +escapeshellarg($new)
 +);
 +exec($cmd, $output);
 +} else {
 +$cmd = sprintf(
 +'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s..%s',
 +\Git::GIT_EXECUTABLE,
 +$repourl,
 +escapeshellarg($old),
 +escapeshellarg($new)
 +);
 +exec($cmd, $output);
 +}
 +
 +return $output;
 +}
 +
  /**
   * Find user name by nickname in users data file
-  * @param $user user nickname
+  * @param string $user user nickname
   * @return string user name
   */
  public function getUserName($user)
@@@ -147,7 -85,7 +149,7 @@@
  if ($ref['reftype'] == self::REF_TAG) {
  $this-sendTagMail($ref['refname'], $ref['changetype'], 
$ref['old'], $ref['new']);
  } elseif ($ref['reftype'] == self::REF_BRANCH){
- $this-sendBranchMail($ref['refname'], $ref['changetype'], 
$ref['old'], $ref['new']);
+ $this-branchesMailIds[$ref['refname']] = 
$this-sendBranchMail($ref['refname'], $ref['changetype'], $ref['old'], 
$ref['new']);
  }
  }
  
@@@ -155,12 -93,11 +157,11 @@@
  foreach ($this-revisions as $revision = $branches) {
  // check if it commit was already in other branches
  if (!$this-isRevExistsInBranches($revision, 
array_diff($this-allBranches, $branches))) {
- $this-sendCommitMail($revision);
+ $this-sendCommitMail($revision, $branches);
  }
  }
  
  }
- 
  /**
   * Send mail about branch.
   * Subject: [git] [branch] 

[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php lib/Git/ReceiveHook.php lib/Mail.php

2012-03-20 Thread Alexander Moskaliov
Commit: 4a6cbdd7b551664f76c536fd67c009ba25c98d2d
Author: Alexander Moskaliov(ir...@php.net) Sun, 18 Mar 2012 19:43:31 
+0400
Committer: Alexander Moskaliov(ir...@php.net)  Sun, 18 Mar 2012 19:43:31 
+0400
Parents: 7c4de5d5a9e10eb0322d87e69f07e32ad843de60

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=4a6cbdd7b551664f76c536fd67c009ba25c98d2d

Log:
add in-reply-to test support  and fix phpdoc

Changed paths:
  M  lib/Git/PostReceiveHook.php
  M  lib/Git/ReceiveHook.php
  M  lib/Mail.php

4a6cbdd7b551664f76c536fd67c009ba25c98d2d
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index 5955bc2..743b6ac 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -17,12 +17,14 @@ class PostReceiveHook extends ReceiveHook
 
 private $allBranches = [];
 
+private $branchesMailIds = [];
+
 /**
- * @param $basePath string base path for all repositories
- * @param $pushAuthor string user who make push
- * @param $usersFile string path to file with users data
- * @param $mailingList string mail recipient
- * @param $emailPrefix string prefix for mail subject
+ * @param string $basePath base path for all repositories
+ * @param string $pushAuthor user who make push
+ * @param string $usersFile path to file with users data
+ * @param string $mailingList mail recipient
+ * @param string $emailPrefix prefix for mail subject
  */
 public function __construct($basePath, $pushAuthor, $usersFile, 
$mailingList, $emailPrefix)
 {
@@ -39,7 +41,7 @@ class PostReceiveHook extends ReceiveHook
 
 /**
  * Find user name by nickname in users data file
- * @param $user user nickname
+ * @param string $user user nickname
  * @return string user name
  */
 public function getUserName($user)
@@ -83,7 +85,7 @@ class PostReceiveHook extends ReceiveHook
 if ($ref['reftype'] == self::REF_TAG) {
 $this-sendTagMail($ref['refname'], $ref['changetype'], 
$ref['old'], $ref['new']);
 } elseif ($ref['reftype'] == self::REF_BRANCH){
-$this-sendBranchMail($ref['refname'], $ref['changetype'], 
$ref['old'], $ref['new']);
+$this-branchesMailIds[$ref['refname']] = 
$this-sendBranchMail($ref['refname'], $ref['changetype'], $ref['old'], 
$ref['new']);
 }
 }
 
@@ -91,12 +93,11 @@ class PostReceiveHook extends ReceiveHook
 foreach ($this-revisions as $revision = $branches) {
 // check if it commit was already in other branches
 if (!$this-isRevExistsInBranches($revision, 
array_diff($this-allBranches, $branches))) {
-$this-sendCommitMail($revision);
+$this-sendCommitMail($revision, $branches);
 }
 }
 
 }
-
 /**
  * Send mail about branch.
  * Subject: [git] [branch] %PROJECT%: %STATUS% branch %BRANCH_NAME%
@@ -119,10 +120,11 @@ class PostReceiveHook extends ReceiveHook
  *
  * --/part1--
  *
- * @param $name string branch fullname (refs/heads/example)
- * @param $changeType int delete, create or update
- * @param $oldrev string old revision
- * @param $newrev string new revision
+ * @param string $name branch fullname (refs/heads/example)
+ * @param int $changeType delete, create or update
+ * @param string $oldrev old revision
+ * @param string $newrev new revision
+ * @return string mail uniq id
  */
 private function sendBranchMail($name, $changeType, $oldrev, $newrev)
 {
@@ -202,12 +204,13 @@ class PostReceiveHook extends ReceiveHook
 
 $mail-send();
 
+return $mail-getId();
 }
 
 
 /**
  * Cache revisions per branche for use it later
- * @param $branchName string branch fullname
+ * @param string $branchName branch fullname
  * @param array $revisions revisions array
  */
 private function cacheRevisions($branchName, array $revisions)
@@ -245,10 +248,10 @@ class PostReceiveHook extends ReceiveHook
  * %PATHS%
  * --/part1--
  *
- * @param $name string tag fullname (refs/tags/example)
- * @param $changeType int delete, create or update
- * @param $oldrev string old revision
- * @param $newrev string new revision
+ * @param string $name tag fullname (refs/tags/example)
+ * @param int $changeType delete, create or update
+ * @param string $oldrev old revision
+ * @param string $newrev new revision
  */
 private function sendTagMail($name, $changeType, $oldrev, $newrev)
 {
@@ -321,7 +324,7 @@ class PostReceiveHook extends ReceiveHook
  * only for annotated tag:
  * 'tagger', 'tagger_email', 'tagger_date' - info about tagger person
  * 'log' - tag message
- * @param $tag string tag fullname
+ * @param string $tag tag fullname
  * @return array array with tag info
  */
 private function getTagInfo($tag)
@@ -351,10 +354,10 @@ class 

[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php

2012-03-20 Thread Alexander Moskaliov
Commit: 11bc19461cfada676edd5852edc529532ef7a3ac
Author: Alexander Moskaliov(ir...@php.net) Tue, 20 Mar 2012 11:36:28 
+0400
Committer: Alexander Moskaliov(ir...@php.net)  Tue, 20 Mar 2012 11:36:28 
+0400
Parents: 9c54157ce5bcc8e2a414014ddd234efedd8d135c

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=11bc19461cfada676edd5852edc529532ef7a3ac

Log:
Add trivial merge.

For merge commits without change any files (trivial merge) we not show changes 
path and diff in mail

Changed paths:
  M  lib/Git/PostReceiveHook.php


Diff:
11bc19461cfada676edd5852edc529532ef7a3ac
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index da755f4..ee3aab7 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -518,7 +518,9 @@ class PostReceiveHook extends ReceiveHook
 }
 
 
-if (strlen($pathsString)  8192) {
+if ($pathsString == '') {
+$message .= \nTrivial merge\n;
+} elseif (strlen($pathsString)  8192) {
 // inline changed paths
 $message .= \nChanged paths:\n . $pathsString . \n;
 if ((strlen($pathsString) + strlen($diff))  8192) {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php

2012-03-20 Thread Alexander Moskaliov
Commit: 9c54157ce5bcc8e2a414014ddd234efedd8d135c
Author: Alexander Moskaliov(ir...@php.net) Tue, 20 Mar 2012 11:31:31 
+0400
Committer: Alexander Moskaliov(ir...@php.net)  Tue, 20 Mar 2012 11:31:31 
+0400
Parents: 42d233ae4752adbce2709553cef0cd456b92a2e0

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=9c54157ce5bcc8e2a414014ddd234efedd8d135c

Log:
Remove not used methods

This methods was moved to bugsweb class early

Changed paths:
  M  lib/Git/PostReceiveHook.php


Diff:
9c54157ce5bcc8e2a414014ddd234efedd8d135c
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index bd3be9b..da755f4 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -39,70 +39,6 @@ class PostReceiveHook extends ReceiveHook
 $this-allBranches = $this-getAllBranches();
 }
 
-
-public function getReceivedMessages()
-{
-$this-hookInput();
-
-$paths = array_map(
-function ($input) {
-return $this-getReceivedMessagesForRange($input['old'], 
$input['new']);
-},
-$this-refs);
-
-/* remove empty lines, and flattern the array */
-$flattend = array_reduce($paths, 'array_merge', []);
-$paths= array_filter($flattend);
-
-return array_unique($paths);
-}
-
-/**
- * Returns an array of commit messages between revision $old and $new.
- *
- * @param string $old The old revison number.
- * @parma string $new The new revison umber.
- *
- * @return array
- */
-private function getReceivedMessagesForRange($old, $new)
-{
-$repourl = \Git::getRepositoryPath();
-$output = [];
-
-if ($old == '') {
-$cmd = sprintf(
-%s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
-self::GIT_EXECUTABLE,
-$repourl
-);
-exec($cmd, $output);
-
-/* do we have heads? otherwise it's a new repo! */
-$heads = implode(' ', $output);
-$not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
-$cmd   = sprintf(
-'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s %s',
-\Git::GIT_EXECUTABLE,
-$repourl,
-$not,
-escapeshellarg($new)
-);
-exec($cmd, $output);
-} else {
-$cmd = sprintf(
-'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s..%s',
-\Git::GIT_EXECUTABLE,
-$repourl,
-escapeshellarg($old),
-escapeshellarg($new)
-);
-exec($cmd, $output);
-}
-
-return $output;
-}
-
 /**
  * Find user name by nickname in users data file
  * @param string $user user nickname
@@ -225,9 +161,6 @@ class PostReceiveHook extends ReceiveHook
 }
 }
 
-
-
-
 $mail = new \Mail();
 $mail-setSubject($this-emailPrefix . ' branch ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php

2012-03-20 Thread Derick Rethans
Commit: 3bacfbd956538305c8f604271071d839ecb1f559
Author: Derick Rethans(git...@derickrethans.nl) Tue, 20 Mar 2012 
08:25:38 +
Committer: Derick Rethans(git...@derickrethans.nl)  Tue, 20 Mar 2012 
08:25:38 +
Parents: bdcf0e849a28c2b06017f225dd488bd26366bf88 
11bc19461cfada676edd5852edc529532ef7a3ac

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=3bacfbd956538305c8f604271071d839ecb1f559

Log:
Merge branch 'master' of git.php.net:/karma

Changed paths:
  MM  lib/Git/PostReceiveHook.php


Diff:
3bacfbd956538305c8f604271071d839ecb1f559
diff --combined lib/Git/PostReceiveHook.php
index b05feca,ee3aab7..4201508
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@@ -39,70 -39,6 +39,6 @@@ class PostReceiveHook extends ReceiveHo
  $this-allBranches = $this-getAllBranches();
  }
  
- 
- public function getReceivedMessages()
- {
- $this-hookInput();
- 
- $paths = array_map(
- function ($input) {
- return $this-getReceivedMessagesForRange($input['old'], 
$input['new']);
- },
- $this-refs);
- 
- /* remove empty lines, and flattern the array */
- $flattend = array_reduce($paths, 'array_merge', []);
- $paths= array_filter($flattend);
- 
- return array_unique($paths);
- }
- 
- /**
-  * Returns an array of commit messages between revision $old and $new.
-  *
-  * @param string $old The old revison number.
-  * @parma string $new The new revison umber.
-  *
-  * @return array
-  */
- private function getReceivedMessagesForRange($old, $new)
- {
- $repourl = \Git::getRepositoryPath();
- $output = [];
- 
- if ($old == '') {
- $cmd = sprintf(
- %s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
- self::GIT_EXECUTABLE,
- $repourl
- );
- exec($cmd, $output);
- 
- /* do we have heads? otherwise it's a new repo! */
- $heads = implode(' ', $output);
- $not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
- $cmd   = sprintf(
- '%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s %s',
- \Git::GIT_EXECUTABLE,
- $repourl,
- $not,
- escapeshellarg($new)
- );
- exec($cmd, $output);
- } else {
- $cmd = sprintf(
- '%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s..%s',
- \Git::GIT_EXECUTABLE,
- $repourl,
- escapeshellarg($old),
- escapeshellarg($new)
- );
- exec($cmd, $output);
- }
- 
- return $output;
- }
- 
  /**
   * Find user name by nickname in users data file
   * @param string $user user nickname
@@@ -225,11 -161,8 +161,8 @@@
  }
  }
  
- 
- 
- 
  $mail = new \Mail();
 -$mail-setSubject($this-emailPrefix . ' branch ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);
 +$mail-setSubject($this-emailPrefix . 'branch ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);
  
  $message = 'Branch ' . $shortname . ' in ' . 
$this-getRepositoryName() . ' was ' . $status[$changeType] . 'd' . \n;
  $message .= 'Date: ' . date('r') . \n;
@@@ -567,7 -500,7 +500,7 @@@
  $diff =  \Git::gitExec('diff-tree -c -p %s', 
escapeshellarg($revision));
  
  $mail = new \Mail();
 -$mail-setSubject($this-emailPrefix . ' commit ' . 
$this-getRepositoryName() . ': ' . implode(' ', array_keys($paths)));
 +$mail-setSubject($this-emailPrefix . 'com ' . 
$this-getRepositoryName() . ': ' . $info['subject'] . ': '. implode(' ', 
array_keys($paths)));
  
  $message = '';
  
@@@ -585,7 -518,9 +518,9 @@@
  }
  
  
- if (strlen($pathsString)  8192) {
+ if ($pathsString == '') {
+ $message .= \nTrivial merge\n;
+ } elseif (strlen($pathsString)  8192) {
  // inline changed paths
  $message .= \nChanged paths:\n . $pathsString . \n;
  if ((strlen($pathsString) + strlen($diff))  8192) {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php

2012-03-20 Thread Derick Rethans
Commit: bdcf0e849a28c2b06017f225dd488bd26366bf88
Author: Derick Rethans(git...@derickrethans.nl) Tue, 20 Mar 2012 
07:59:37 +
Committer: Derick Rethans(git...@derickrethans.nl)  Tue, 20 Mar 2012 
07:59:37 +
Parents: 3586d1c6652ce0f202daa2894d7862ff4e698140

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=bdcf0e849a28c2b06017f225dd488bd26366bf88

Log:
Add commit message subject and change commit to com to save space.

Changed paths:
  M  lib/Git/PostReceiveHook.php


Diff:
bdcf0e849a28c2b06017f225dd488bd26366bf88
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index 4aec7b7..b05feca 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -567,7 +567,7 @@ class PostReceiveHook extends ReceiveHook
 $diff =  \Git::gitExec('diff-tree -c -p %s', 
escapeshellarg($revision));
 
 $mail = new \Mail();
-$mail-setSubject($this-emailPrefix . 'commit ' . 
$this-getRepositoryName() . ': ' . implode(' ', array_keys($paths)));
+$mail-setSubject($this-emailPrefix . 'com ' . 
$this-getRepositoryName() . ': ' . $info['subject'] . ': '. implode(' ', 
array_keys($paths)));
 
 $message = '';


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git/ReceiveHook.php

2012-03-20 Thread Derick Rethans
Commit: 3586d1c6652ce0f202daa2894d7862ff4e698140
Author: Derick Rethans(git...@derickrethans.nl) Tue, 20 Mar 2012 
07:55:09 +
Committer: Derick Rethans(git...@derickrethans.nl)  Tue, 20 Mar 2012 
07:55:09 +
Parents: eb514083bf2a6ddaa0f2404da3d4347d2747a22e

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=3586d1c6652ce0f202daa2894d7862ff4e698140

Log:
Removed the .git part of the repository name as specified by the methods 
docblock.

This also gets rid of the superfluous .git in email subjects.

Changed paths:
  M  lib/Git/ReceiveHook.php


Diff:
3586d1c6652ce0f202daa2894d7862ff4e698140
diff --git a/lib/Git/ReceiveHook.php b/lib/Git/ReceiveHook.php
index b526e9a..294bb27 100644
--- a/lib/Git/ReceiveHook.php
+++ b/lib/Git/ReceiveHook.php
@@ -47,7 +47,7 @@ abstract class ReceiveHook
  */
 public function getRepositoryName()
 {
-return $this-repositoryName;
+return preg_replace('@\.git$@', '', $this-repositoryName);
 }
 
 /**


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: hooks/post-receive.mail lib/Git/PostReceiveHook.php

2012-03-20 Thread Derick Rethans
Commit: eb514083bf2a6ddaa0f2404da3d4347d2747a22e
Author: Derick Rethans(git...@derickrethans.nl) Tue, 20 Mar 2012 
07:50:06 +
Committer: Derick Rethans(git...@derickrethans.nl)  Tue, 20 Mar 2012 
07:54:58 +
Parents: 42d233ae4752adbce2709553cef0cd456b92a2e0

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=eb514083bf2a6ddaa0f2404da3d4347d2747a22e

Log:
Don't use an email prefix unless specifically configured.

This gets rid of the superfluous [git]  in every mail subject to PHP-CVS.

Changed paths:
  M  hooks/post-receive.mail
  M  lib/Git/PostReceiveHook.php


Diff:
eb514083bf2a6ddaa0f2404da3d4347d2747a22e
diff --git a/hooks/post-receive.mail b/hooks/post-receive.mail
index 7d47619..de24b77 100755
--- a/hooks/post-receive.mail
+++ b/hooks/post-receive.mail
@@ -30,7 +30,10 @@ include 'Git/PostReceiveHook.php';
 
 
 $recipients = exec('git config hooks.mailinglist');
-$emailPrefix = exec('git config hooks.emailprefix') ?: '[git]';
+$emailPrefix = exec('git config hooks.emailprefix');
+if ($emailprefix != '') {
+   $emailprefix . ' ';
+}
 
 $user = null;
 if (getenv('REMOTE_USER')) {
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index bd3be9b..4aec7b7 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -229,7 +229,7 @@ class PostReceiveHook extends ReceiveHook
 
 
 $mail = new \Mail();
-$mail-setSubject($this-emailPrefix . ' branch ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);
+$mail-setSubject($this-emailPrefix . 'branch ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);
 
 $message = 'Branch ' . $shortname . ' in ' . 
$this-getRepositoryName() . ' was ' . $status[$changeType] . 'd' . \n;
 $message .= 'Date: ' . date('r') . \n;
@@ -567,7 +567,7 @@ class PostReceiveHook extends ReceiveHook
 $diff =  \Git::gitExec('diff-tree -c -p %s', 
escapeshellarg($revision));
 
 $mail = new \Mail();
-$mail-setSubject($this-emailPrefix . ' commit ' . 
$this-getRepositoryName() . ': ' . implode(' ', array_keys($paths)));
+$mail-setSubject($this-emailPrefix . 'commit ' . 
$this-getRepositoryName() . ': ' . implode(' ', array_keys($paths)));
 
 $message = '';


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: hooks/post-receive.mail

2012-03-19 Thread David Soria Parra
Commit: dbda495a2985d4447f629bf50adbae16ee518dc3
Author: David Soria Parra(d...@php.net) Mon, 19 Mar 2012 16:17:23 +0100
Committer: David Soria Parra(d...@php.net)  Mon, 19 Mar 2012 16:17:23 +0100
Parents: efd58e9da03931adc336fbf3400a94d4103f5fbf

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=dbda495a2985d4447f629bf50adbae16ee518dc3

Log:
Do not send mails when we have no receipients

Changed paths:
  M  hooks/post-receive.mail


Diff:
dbda495a2985d4447f629bf50adbae16ee518dc3
diff --git a/hooks/post-receive.mail b/hooks/post-receive.mail
index 8814b35..7d47619 100755
--- a/hooks/post-receive.mail
+++ b/hooks/post-receive.mail
@@ -40,11 +40,13 @@ if (getenv('REMOTE_USER')) {
 $user = getenv('GL_USER');
 }
 
-$hook = new \Git\PostReceiveHook(
-getenv('GL_REPO_BASE_ABS') ?: REPOSITORY_PATH,
-$user,
-getenv('USERS_DB_FILE') ?: USERS_DB_FILE,
-$recipients,
-$emailPrefix
-);
-$hook-process();
\ No newline at end of file
+if (!empty($recipients)) {
+$hook = new \Git\PostReceiveHook(
+getenv('GL_REPO_BASE_ABS') ?: REPOSITORY_PATH,
+$user,
+getenv('USERS_DB_FILE') ?: USERS_DB_FILE,
+$recipients,
+$emailPrefix
+);
+$hook-process();
+}



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: hooks/post-receive.bugsweb lib/Git/BugsWebPostReceiveHook.php

2012-03-19 Thread David Soria Parra
Commit: efd58e9da03931adc336fbf3400a94d4103f5fbf
Author: Florian Anderiasch(f...@php.net) Mon, 19 Mar 2012 16:03:36 +0100
Committer: Florian Anderiasch(f...@php.net)  Mon, 19 Mar 2012 16:03:36 +0100
Parents: db438a4a9ec117fec2767de6a0f79147d48285cc

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=efd58e9da03931adc336fbf3400a94d4103f5fbf

Log:
Update to changed ReceiveHook

Changed paths:
  M  hooks/post-receive.bugsweb
  A  lib/Git/BugsWebPostReceiveHook.php


Diff:
efd58e9da03931adc336fbf3400a94d4103f5fbf
diff --git a/hooks/post-receive.bugsweb b/hooks/post-receive.bugsweb
index 9ab2bc3..1c53f0d 100755
--- a/hooks/post-receive.bugsweb
+++ b/hooks/post-receive.bugsweb
@@ -16,6 +16,7 @@ include 'Git.php';
 include 'Git/PushInformation.php';
 include 'Git/ReceiveHook.php';
 include 'Git/PostReceiveHook.php';
+include 'Git/BugsWebPostReceiveHook.php';
 
 $recipients = exec('git config hooks.mailinglist');
 $emailPrefix = exec('git config hooks.emailprefix') ?: '[git]';
@@ -28,7 +29,7 @@ if (getenv('REMOTE_USER')) {
 $user = getenv('GL_USER');
 }
 
-$hook = new \Git\PostReceiveHook(KARMA_FILE, REPOSITORY_PATH);
+$hook = new \Git\BugsWebPostReceiveHook(KARMA_FILE, REPOSITORY_PATH);
 $rpath = $hook-getReceivedMessages(
 getenv('GL_REPO_BASE_ABS') ?: REPOSITORY_PATH,
 $user,
diff --git a/lib/Git/BugsWebPostReceiveHook.php 
b/lib/Git/BugsWebPostReceiveHook.php
new file mode 100644
index 000..13e263b
--- /dev/null
+++ b/lib/Git/BugsWebPostReceiveHook.php
@@ -0,0 +1,69 @@
+?php
+namespace Git;
+
+class BugsWebPostReceiveHook extends ReceiveHook
+{
+
+public function getReceivedMessages()
+{
+$this-hookInput();
+
+$paths = array_map(
+function ($input) {
+return $this-getReceivedMessagesForRange($input['old'], 
$input['new']);
+},
+$this-refs);
+
+/* remove empty lines, and flattern the array */
+$flattend = array_reduce($paths, 'array_merge', []);
+$paths= array_filter($flattend);
+
+return array_unique($paths);
+}
+
+/**
+ * Returns an array of commit messages between revision $old and $new.
+ *
+ * @param string $old The old revison number.
+ * @parma string $new The new revison umber.
+ *
+ * @return array
+ */
+private function getReceivedMessagesForRange($old, $new)
+{
+$repourl = \Git::getRepositoryPath();
+$output = [];
+
+if ($old == '') {
+$cmd = sprintf(
+%s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
+self::GIT_EXECUTABLE,
+$repourl
+);
+exec($cmd, $output);
+
+/* do we have heads? otherwise it's a new repo! */
+$heads = implode(' ', $output);
+$not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
+$cmd   = sprintf(
+'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s %s',
+\Git::GIT_EXECUTABLE,
+$repourl,
+$not,
+escapeshellarg($new)
+);
+exec($cmd, $output);
+} else {
+$cmd = sprintf(
+'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s..%s',
+\Git::GIT_EXECUTABLE,
+$repourl,
+escapeshellarg($old),
+escapeshellarg($new)
+);
+exec($cmd, $output);
+}
+
+return $output;
+}
+}
\ No newline at end of file



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git:

2012-03-19 Thread David Soria Parra
Commit: 646e2bada8160e850b3f5cc004a83d3a798ae2e1
Author: David Soria Parra(d...@php.net) Mon, 19 Mar 2012 16:25:09 +0100
Committer: David Soria Parra(d...@php.net)  Mon, 19 Mar 2012 16:25:09 +0100
Parents: dbda495a2985d4447f629bf50adbae16ee518dc3 
12b54a31f612d05c24c6c273589dc9e6adb38833

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=646e2bada8160e850b3f5cc004a83d3a798ae2e1

Log:
Merge branch 'master' of git://github.com/winks/karma

Changed paths:


Diff:
646e2bada8160e850b3f5cc004a83d3a798ae2e1



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: hooks/post-receive.bugsweb

2012-03-19 Thread David Soria Parra
Commit: 12b54a31f612d05c24c6c273589dc9e6adb38833
Author: Florian Anderiasch(f...@php.net) Mon, 19 Mar 2012 16:21:18 +0100
Committer: Florian Anderiasch(f...@php.net)  Mon, 19 Mar 2012 16:21:18 +0100
Parents: efd58e9da03931adc336fbf3400a94d4103f5fbf

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=12b54a31f612d05c24c6c273589dc9e6adb38833

Log:
Remove superfluous include

Changed paths:
  M  hooks/post-receive.bugsweb


Diff:
12b54a31f612d05c24c6c273589dc9e6adb38833
diff --git a/hooks/post-receive.bugsweb b/hooks/post-receive.bugsweb
index 1c53f0d..683ffe2 100755
--- a/hooks/post-receive.bugsweb
+++ b/hooks/post-receive.bugsweb
@@ -15,7 +15,6 @@ set_include_path(
 include 'Git.php';
 include 'Git/PushInformation.php';
 include 'Git/ReceiveHook.php';
-include 'Git/PostReceiveHook.php';
 include 'Git/BugsWebPostReceiveHook.php';
 
 $recipients = exec('git config hooks.mailinglist');



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: hooks/post-receive

2012-03-19 Thread David Soria Parra
Commit: a805c5336965215eda3f10c6ad33b5f9e8b93f83
Author: David Soria Parra(d...@php.net) Mon, 19 Mar 2012 17:36:35 +0100
Committer: David Soria Parra(d...@php.net)  Mon, 19 Mar 2012 17:36:35 +0100
Parents: 646e2bada8160e850b3f5cc004a83d3a798ae2e1

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=a805c5336965215eda3f10c6ad33b5f9e8b93f83

Log:
Renable bugsweb script

Changed paths:
  M  hooks/post-receive


Diff:
a805c5336965215eda3f10c6ad33b5f9e8b93f83
diff --git a/hooks/post-receive b/hooks/post-receive
index a27808f..2016acb 100755
--- a/hooks/post-receive
+++ b/hooks/post-receive
@@ -1,4 +1,4 @@
 #!/bin/sh
 [ -f 'hooks/post-receive.mail' ] hooks/post-receive.mail
-# [ -f 'hooks/post-receive.bugsweb' ]  hooks/post-receive.bugsweb
+[ -f 'hooks/post-receive.bugsweb' ]  hooks/post-receive.bugsweb
 [ -f 'hooks/post-receive.mirror' ]   hooks/post-receive.mirror



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git/BugsWebPostReceiveHook.php

2012-03-19 Thread David Soria Parra
Commit: a906187e5b716c29691abfe44d1dc876232b711d
Author: David Soria Parra(d...@php.net) Mon, 19 Mar 2012 18:16:10 +0100
Committer: David Soria Parra(d...@php.net)  Mon, 19 Mar 2012 18:16:10 +0100
Parents: a805c5336965215eda3f10c6ad33b5f9e8b93f83

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=a906187e5b716c29691abfe44d1dc876232b711d

Log:
Use the right GIT_EXECUTABLE constant

Changed paths:
  M  lib/Git/BugsWebPostReceiveHook.php


Diff:
a906187e5b716c29691abfe44d1dc876232b711d
diff --git a/lib/Git/BugsWebPostReceiveHook.php 
b/lib/Git/BugsWebPostReceiveHook.php
index 13e263b..ee54826 100644
--- a/lib/Git/BugsWebPostReceiveHook.php
+++ b/lib/Git/BugsWebPostReceiveHook.php
@@ -37,7 +37,7 @@ class BugsWebPostReceiveHook extends ReceiveHook
 if ($old == '') {
 $cmd = sprintf(
 %s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
-self::GIT_EXECUTABLE,
+\Git::GIT_EXECUTABLE,
 $repourl
 );
 exec($cmd, $output);
@@ -66,4 +66,4 @@ class BugsWebPostReceiveHook extends ReceiveHook
 
 return $output;
 }
-}
\ No newline at end of file
+}



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git.php

2012-03-19 Thread David Soria Parra
Commit: 04cd724385b1ccb846f846d14250caf34628d0f4
Author: David Soria Parra(d...@php.net) Mon, 19 Mar 2012 18:48:32 +0100
Committer: David Soria Parra(d...@php.net)  Mon, 19 Mar 2012 18:48:32 +0100
Parents: a906187e5b716c29691abfe44d1dc876232b711d

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=04cd724385b1ccb846f846d14250caf34628d0f4

Log:
Make sure we strip the output before

Changed paths:
  M  lib/Git.php


Diff:
04cd724385b1ccb846f846d14250caf34628d0f4
diff --git a/lib/Git.php b/lib/Git.php
index fc0f0c9..04e4d44 100644
--- a/lib/Git.php
+++ b/lib/Git.php
@@ -40,6 +40,6 @@ class Git
 array_shift($args);
 $cmd = vsprintf($cmd, $args);
 $output = shell_exec($cmd);
-return (string)$output;
+return trim($output);
 }
 }



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git] commit karma.git: lib/Git/PostReceiveHook.php

2012-03-19 Thread David Soria Parra
Commit: c3c822e0f983c7514f8043ec11ceeef9c80100c0
Author: David Soria Parra(d...@php.net) Mon, 19 Mar 2012 22:12:42 +0100
Committer: David Soria Parra(d...@php.net)  Mon, 19 Mar 2012 22:12:42 +0100
Parents: 04cd724385b1ccb846f846d14250caf34628d0f4

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=c3c822e0f983c7514f8043ec11ceeef9c80100c0

Log:
Initialize logString

Changed paths:
  M  lib/Git/PostReceiveHook.php


Diff:
c3c822e0f983c7514f8043ec11ceeef9c80100c0
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index 15487ca..633ff77 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -191,6 +191,7 @@ class PostReceiveHook extends ReceiveHook
 private function sendBranchMail($name, $changeType, $oldrev, $newrev)
 {
 
+$logString = '';
 $status = [self::TYPE_UPDATED = 'update', self::TYPE_CREATED = 
'create', self::TYPE_DELETED = 'delete'];
 $shortname = str_replace('refs/heads/', '', $name);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: hooks/commit-bugs.php hooks/post-receive.bugsweb

2012-03-18 Thread David Soria Parra
Commit: 9ae86325126874f4645c8bf4ed4ac156b97d9bdc
Author: Florian Anderiasch(f...@php.net) Thu, 8 Mar 2012 09:27:53 +0100
Committer: Florian Anderiasch(f...@php.net)  Thu, 8 Mar 2012 09:27:53 +0100
Parents: 7d3adc9b7f30027dadbccf1038979cbcd7bff94d

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=9ae86325126874f4645c8bf4ed4ac156b97d9bdc

Log:
Add slightly adapted commit-bugs.php and hook script

Changed paths:
  M  hooks/commit-bugs.php
  A  hooks/post-receive.bugsweb


Diff:
9ae86325126874f4645c8bf4ed4ac156b97d9bdc
diff --git a/hooks/commit-bugs.php b/hooks/commit-bugs.php
index f62cb8b..df5b913 100644
--- a/hooks/commit-bugs.php
+++ b/hooks/commit-bugs.php
@@ -13,7 +13,7 @@ $bug_url_prefixes = array(
 '' = 'https://bugs.php.net',
 );
 $bug_rpc_url = 'https://bugs.php.net/rpc.php';
-$viewvc_url_prefix = 'http://svn.php.net/viewvc/?view=revisionrevision=';
+//$viewvc_url_prefix = 'http://svn.php.net/viewvc/?view=revisionrevision=';
 
 // 
-
 // Get the list of mentioned bugs from the commit log
diff --git a/hooks/post-receive.bugsweb b/hooks/post-receive.bugsweb
new file mode 100755
index 000..9dc403f
--- /dev/null
+++ b/hooks/post-receive.bugsweb
@@ -0,0 +1,62 @@
+#!/usr/bin/env php
+?php
+namespace Karma;
+
+const KARMA_FILE = '/git/checkout/SVNROOT/global_avail';
+const REPOSITORY_PATH = '/git/repositories';
+const LIB_PATH = '/git/checkout/karma/lib';
+
+set_include_path(
+getenv('KARMA_LIB_PATH') ?: LIB_PATH .
+PATH_SEPARATOR .
+get_include_path());
+
+include 'Git.php';
+include 'Git/PushInformation.php';
+include 'Git/ReceiveHook.php';
+
+$hook = new \Git\ReceiveHook(KARMA_FILE, REPOSITORY_PATH);
+$rpath = $hook-getReceivedMessages();
+
+$template = Automatic comment from GIT on behalf of %s
+Revision: http://git.php.net/%s
+Log: %s;
+
+foreach ($rpath as $commit) {
+// should look like this: [u...@php.net] 0df3233344 Fixed bug #1234 It 
works!
+$pattern = '(\[([^\]]+)\] ([0-9a-f]+)(.*Fix(ed)? (bug )?\#([0-9]+)(.*)))i';
+preg_match($pattern, $commit, $matches);
+
+if (!isset($matches[1])) {
+continue;
+}
+
+$committer  = $matches[1];
+$commitHash = $matches[2];
+$commitMsg  = trim($matches[3]);
+$bugNumber  = $matches[6];
+$shortMsg   = trim($matches[7]);
+if ($shortMsg[0] == '(') {
+$shortMsg = substr($shortMsg, 1);
+}
+if ($shortMsg[strlen($shortMsg)-1] == ')') {
+$shortMsg = substr($shortMsg, 0, -1);
+}
+
+$output = sprintf(
+$template,
+$committer,
+$commitHash,
+$commitMsg
+);
+
+$commit_info = array();
+$commit_info['log_message'] = $commitMsg;
+$commit_info['author'] = $committer;
+$viewvc_url_prefix = sprintf(
+'http://git.php.net/?p=%s.git;a=commit;h=',
+$hook-getRepositoryName()
+);
+$REV = $commitHash;
+require __DIR__ . '/commit-bugs.php';
+}



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: lib/Git/ReceiveHook.php

2012-03-18 Thread David Soria Parra
Commit: 7d3adc9b7f30027dadbccf1038979cbcd7bff94d
Author: Florian Anderiasch(f...@php.net) Thu, 8 Mar 2012 09:08:24 +0100
Committer: Florian Anderiasch(f...@php.net)  Thu, 8 Mar 2012 09:08:24 +0100
Parents: e6da86fbb22bc773980c2ecde77bb8875641a097

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=7d3adc9b7f30027dadbccf1038979cbcd7bff94d

Log:
Merge last refactoring steps

Changed paths:
  M  lib/Git/ReceiveHook.php


Diff:
7d3adc9b7f30027dadbccf1038979cbcd7bff94d
diff --git a/lib/Git/ReceiveHook.php b/lib/Git/ReceiveHook.php
index f90df10..87c4b54 100644
--- a/lib/Git/ReceiveHook.php
+++ b/lib/Git/ReceiveHook.php
@@ -139,7 +139,7 @@ class ReceiveHook
  */
 private function getReceivedMessagesForRange($old, $new)
 {
-$repourl = $this-getRepositoryPath();
+$repourl = \Git::getRepositoryPath();
 $output = [];
 
 if ($old == '') {
@@ -155,7 +155,7 @@ class ReceiveHook
 $not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
 $cmd   = sprintf(
 '%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s %s',
-self::GIT_EXECUTABLE,
+\Git::GIT_EXECUTABLE,
 $repourl,
 $not,
 escapeshellarg($new)
@@ -164,7 +164,7 @@ class ReceiveHook
 } else {
 $cmd = sprintf(
 '%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s..%s',
-self::GIT_EXECUTABLE,
+\Git::GIT_EXECUTABLE,
 $repourl,
 escapeshellarg($old),
 escapeshellarg($new)



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: lib/Git/ReceiveHook.php

2012-03-18 Thread David Soria Parra
Commit: e6da86fbb22bc773980c2ecde77bb8875641a097
Author: Florian Anderiasch(f...@php.net) Thu, 8 Mar 2012 08:49:25 +0100
Committer: Florian Anderiasch(f...@php.net)  Thu, 8 Mar 2012 08:49:25 +0100
Parents: 275c3770c3bc0ce710328cd2b35989f18e02ecc9 
fc9c78fe12aa756060684e565adf8fb8a4373120

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=e6da86fbb22bc773980c2ecde77bb8875641a097

Log:
Merge branch 'master' of https://git.php.net/repository/karma

Changed paths:
  MM  lib/Git/ReceiveHook.php


Diff:
e6da86fbb22bc773980c2ecde77bb8875641a097
diff --combined lib/Git/ReceiveHook.php
index 8faadcd,b51a5f4..f90df10
--- a/lib/Git/ReceiveHook.php
+++ b/lib/Git/ReceiveHook.php
@@@ -3,7 -3,6 +3,6 @@@ namespace Git
  
  class ReceiveHook
  {
- const GIT_EXECUTABLE = 'git';
  const INPUT_PATTERN = '@^([0-9a-f]{40}) ([0-9a-f]{40}) (.+)$@i';
  
  private $karmaFile;
@@@ -22,7 -21,7 +21,7 @@@
   */
  public function isKarmaIgnored()
  {
- return 'true' === exec(sprintf('%s config karma.ignored', 
self::GIT_EXECUTABLE));
+ return 'true' === exec(sprintf('%s config karma.ignored', 
\Git::GIT_EXECUTABLE));
  }
  
  /**
@@@ -35,7 -34,7 +34,7 @@@
   */
  public function getRepositoryName()
  {
- $rel_path = str_replace($this-repositoryBasePath, '', 
$this-getRepositoryPath());
+ $rel_path = str_replace($this-repositoryBasePath, '', 
\Git::getRepositoryPath());
  if (preg_match('@/(.*\.git)$@', $rel_path, $matches)) {
  return $matches[1];
  }
@@@ -43,22 -42,13 +42,13 @@@
  return '';
  }
  
- /**
-  * Returns the path to the current repository.
-  *
-  * Tries to determine the path of the current repository in which
-  * the hook was invoked.
-  *
-  * @return string
-  */
- public function getRepositoryPath()
- {
- $path = exec(sprintf('%s rev-parse --git-dir', self::GIT_EXECUTABLE));
- if (!is_dir($path)) {
- return false;
+ public function mapInput(callable $fn) {
+ $result = [];
+ foreach($this-hookInput() as $input) {
+ $result[] = $fn($input['old'], $input['new']);
  }
  
- return realpath($path);
+ return $result;
  }
  
  /**
@@@ -109,77 -99,36 +99,82 @@@
   */
  private function getReceivedPathsForRange($old, $new)
  {
- $repourl = $this-getRepositoryPath();
+ $repourl = \Git::getRepositoryPath();
  $output  = [];
  
  /* there is the case where we push a new branch. check only new 
commits.
 in case its a brand new repo, no heads will be available. */
- if ($old == '') {
+ if ($old == \Git::NULLREV) {
  exec(
  sprintf(%s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
- self::GIT_EXECUTABLE, $repourl), $output);
+ \Git::GIT_EXECUTABLE, $repourl), $output);
  /* do we have heads? otherwise it's a new repo! */
- $heads = implode(' ', $output);
- $not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
+ if (count($output)  0) {
+ $not = array_map(
+ function($x) {
+ return sprintf('--not %s', escapeshellarg($x));
+ }, $output);
+ $not = implode(' ', $not);
+ }
  exec(
  sprintf('%s --git-dir=%s log --name-only --pretty=format: 
%s %s',
- self::GIT_EXECUTABLE, $repourl, $not,
+ \Git::GIT_EXECUTABLE, $repourl, $not,
  escapeshellarg($new)), $output);
  } else {
  exec(
  sprintf('%s --git-dir=%s log --name-only --pretty=format: 
%s..%s',
- self::GIT_EXECUTABLE, $repourl, escapeshellarg($old),
+ \Git::GIT_EXECUTABLE, $repourl, escapeshellarg($old),
  escapeshellarg($new)), $output);
  }
  return $output;
  }
  
 +/**
 + * Returns an array of commit messages between revision $old and $new.
 + *
 + * @param string $old The old revison number.
 + * @parma string $new The new revison umber.
 + *
 + * @return array
 + */
 +private function getReceivedMessagesForRange($old, $new)
 +{
 +$repourl = $this-getRepositoryPath();
 +$output = [];
 +
 +if ($old == '') {
 +$cmd = sprintf(
 +%s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
 +self::GIT_EXECUTABLE,
 +$repourl
 +);
 +exec($cmd, $output);
 +
 +/* do we have heads? otherwise it's a new repo! */
 +$heads = implode(' ', $output);
 +

[PHP-CVS] [git][commit] karma.git: hooks/commit-bugs.php

2012-03-18 Thread David Soria Parra
Commit: 275c3770c3bc0ce710328cd2b35989f18e02ecc9
Author: Florian Anderiasch(f...@php.net) Thu, 8 Mar 2012 08:32:07 +0100
Committer: Florian Anderiasch(f...@php.net)  Thu, 8 Mar 2012 08:32:07 +0100
Parents: 2f637ccbfef5fcd60b2e905ea486b60100c020e2

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=275c3770c3bc0ce710328cd2b35989f18e02ecc9

Log:
Added commit-bugs.php from SVNROOT

Changed paths:
  A  hooks/commit-bugs.php


Diff:
275c3770c3bc0ce710328cd2b35989f18e02ecc9
diff --git a/hooks/commit-bugs.php b/hooks/commit-bugs.php
new file mode 100644
index 000..f62cb8b
--- /dev/null
+++ b/hooks/commit-bugs.php
@@ -0,0 +1,112 @@
+?php
+
+// This script is intended to be called from post-commit. It assumes that all
+//  the appropriate variables and functions are defined.
+
+// 
-
+// Constants
+$bug_pattern = '/(?:(pecl|pear|php)\s*)?(?:bug|#)[\s#:]*([0-9]+)/iuX';
+$bug_url_prefixes = array(
+'pear' = 'http://pear.php.net/bugs',
+'pecl' = 'https://bugs.php.net',
+'php' = 'https://bugs.php.net',
+'' = 'https://bugs.php.net',
+);
+$bug_rpc_url = 'https://bugs.php.net/rpc.php';
+$viewvc_url_prefix = 'http://svn.php.net/viewvc/?view=revisionrevision=';
+
+// 
-
+// Get the list of mentioned bugs from the commit log
+if (preg_match_all($bug_pattern, $commit_info['log_message'], $matched_bugs, 
PREG_SET_ORDER)  1) {
+// If no bugs matched, we don't have to do anything.
+return;
+}
+
+// 
-
+// Pick the default bug project out the of the path in the first changed dir
+switch (strtolower(substr($commit_info['dirs_changed'][0], 0, 4))) {
+case 'pear':
+$bug_project_default = 'pear';
+break;
+case 'pecl':
+$bug_project_default = 'pecl';
+break;
+default:
+$bug_project_default = '';
+break;
+}
+
+// 
-
+// Process the matches
+$bug_list = array();
+foreach ($matched_bugs as $matched_bug) {
+$bug = array();
+$bug['project'] = $matched_bug[1] ===  ? $bug_project_default : 
strtolower($matched_bug[1]);
+$bug['number'] = intval($matched_bug[2]);
+$bugid = $bug['project'] . $bug['number'];
+$url_prefix = isset($bug_url_prefixes[$bug['project']]) ? 
$bug_url_prefixes[$bug['project']] : $bug_url_prefixes[''];
+$bug['url'] = $url_prefix . '/' . $bug['number'];
+$bug['status'] = 'unknown';
+$bug['short_desc'] = '';
+$bug_list[$bugid] = $bug;
+}
+
+// 
-
+// Make an RPC call for each bug
+include __DIR__ . '/secret.inc';
+foreach ($bug_list as $k = $bug) {
+if (!in_array($bug[project], array(php, pecl, ))) {
+continue;
+}
+
+$comment = Automatic comment on behalf of {$commit_info['author']}\n .
+   Revision: {$viewvc_url_prefix}{$REV}\n .
+   Log: {$commit_info['log_message']}\n;
+
+$postdata = array(
+'user' = $commit_info['author'],
+'id' = $bug['number'],
+'ncomment' = $comment,
+'MAGIC_COOKIE' = $SVN_MAGIC_COOKIE,
+);
+if ($is_DEBUG) {
+unset($postdata['ncomment']);
+$postdata['getbug'] = 1;
+}
+array_walk($postdata, create_function('$v, $k', '$v = rawurlencode($k) . 
= . rawurlencode($v);'));
+$postdata = implode('', $postdata);
+
+// Hook an env var so emails can be resent without messing with bugs
+if (getenv('NOBUG')) {
+continue;
+}
+
+$ch = curl_init();
+curl_setopt_array($ch, array(
+CURLOPT_URL = $bug_rpc_url,
+CURLOPT_RETURNTRANSFER = TRUE,
+CURLOPT_POST = TRUE,
+CURLOPT_CONNECTTIMEOUT = 5,
+CURLOPT_TIMEOUT = 5,
+CURLOPT_POSTFIELDS = $postdata,
+));
+
+$result = curl_exec($ch);
+
+if ($result === FALSE) {
+$bug_list[$k]['error'] = curl_error($ch);
+} else {
+$bug_server_data = json_decode($result, TRUE);
+if (isset($bug_server_data['result']['status'])) {
+$bug_list[$k]['status'] = 
$bug_server_data['result']['status']['status'];
+$bug_list[$k]['short_desc'] = 
$bug_server_data['result']['status']['sdesc'];
+} else {
+$bug_list[$k]['error'] = $bug_server_data['result']['error'];
+}
+}
+curl_close($ch);
+}
+unset($SVN_MAGIC_COOKIE);
+
+// $bug_list is now available to later-running hooks
+?



--
PHP CVS Mailing List 

[PHP-CVS] [git][commit] karma.git: lib/Git/ReceiveHook.php

2012-03-18 Thread David Soria Parra
Commit: 2f637ccbfef5fcd60b2e905ea486b60100c020e2
Author: Florian Anderiasch(f...@php.net) Thu, 8 Mar 2012 07:14:08 +0100
Committer: Florian Anderiasch(f...@php.net)  Thu, 8 Mar 2012 07:14:08 +0100
Parents: 8d595325d65b7de86651483a1705a0ee2a4b4bd5

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=2f637ccbfef5fcd60b2e905ea486b60100c020e2

Log:
Add methods to extract commit messages

Changed paths:
  M  lib/Git/ReceiveHook.php


Diff:
2f637ccbfef5fcd60b2e905ea486b60100c020e2
diff --git a/lib/Git/ReceiveHook.php b/lib/Git/ReceiveHook.php
index 6776a2a..8faadcd 100644
--- a/lib/Git/ReceiveHook.php
+++ b/lib/Git/ReceiveHook.php
@@ -134,6 +134,52 @@ class ReceiveHook
 return $output;
 }
 
+/**
+ * Returns an array of commit messages between revision $old and $new.
+ *
+ * @param string $old The old revison number.
+ * @parma string $new The new revison umber.
+ *
+ * @return array
+ */
+private function getReceivedMessagesForRange($old, $new)
+{
+$repourl = $this-getRepositoryPath();
+$output = [];
+
+if ($old == '') {
+$cmd = sprintf(
+%s --git-dir=%s for-each-ref --format='%%(refname)' 
'refs/heads/*',
+self::GIT_EXECUTABLE,
+$repourl
+);
+exec($cmd, $output);
+
+/* do we have heads? otherwise it's a new repo! */
+$heads = implode(' ', $output);
+$not   = count($output)  0 ? sprintf('--not %s', 
escapeshellarg($heads)) : '';
+$cmd   = sprintf(
+'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s %s',
+self::GIT_EXECUTABLE,
+$repourl,
+$not,
+escapeshellarg($new)
+);
+exec($cmd, $output);
+} else {
+$cmd = sprintf(
+'%s --git-dir=%s log --pretty=format:[%%ae] %%H %%s %s..%s',
+self::GIT_EXECUTABLE,
+$repourl,
+escapeshellarg($old),
+escapeshellarg($new)
+);
+exec($cmd, $output);
+}
+
+return $output;
+}
+
 public function getReceivedPaths()
 {
 $parsed_input = $this-hookInput();
@@ -150,4 +196,21 @@ class ReceiveHook
 
 return array_unique($paths);
 }
+
+public function getReceivedMessages()
+{
+$parsed_input = $this-hookInput();
+
+$paths = array_map(
+function ($input) {
+return $this-getReceivedMessagesForRange($input['old'], 
$input['new']);
+},
+$parsed_input);
+
+/* remove empty lines, and flattern the array */
+$flattend = array_reduce($paths, 'array_merge', []);
+$paths= array_filter($flattend);
+
+return array_unique($paths);
+}
 }



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: hooks/post-receive.bugsweb

2012-03-18 Thread David Soria Parra
Commit: 2957304097591a898fe015a3a16e47fba6842dbc
Author: David Soria Parra(d...@php.net) Sun, 18 Mar 2012 21:13:37 +0100
Committer: David Soria Parra(d...@php.net)  Sun, 18 Mar 2012 21:13:37 +0100
Parents: b6951f77158b0e27b2f13ebd42475c409c0e7861

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=2957304097591a898fe015a3a16e47fba6842dbc

Log:
Call the constructor correct

Changed paths:
  M  hooks/post-receive.bugsweb


Diff:
2957304097591a898fe015a3a16e47fba6842dbc
diff --git a/hooks/post-receive.bugsweb b/hooks/post-receive.bugsweb
index 39e6f9c..19a290e 100755
--- a/hooks/post-receive.bugsweb
+++ b/hooks/post-receive.bugsweb
@@ -5,6 +5,7 @@ namespace Karma;
 const KARMA_FILE = '/git/checkout/SVNROOT/global_avail';
 const REPOSITORY_PATH = '/git/repositories';
 const LIB_PATH = '/git/checkout/karma/lib';
+const USERS_DB_FILE = '/git/users.db';
 
 set_include_path(
 getenv('KARMA_LIB_PATH') ?: LIB_PATH .
@@ -17,7 +18,12 @@ include 'Git/ReceiveHook.php';
 include 'Git/PostReceiveHook.php';
 
 $hook = new \Git\PostReceiveHook(KARMA_FILE, REPOSITORY_PATH);
-$rpath = $hook-getReceivedMessages();
+$rpath = $hook-getReceivedMessages(
+getenv('GL_REPO_BASE_ABS') ?: REPOSITORY_PATH,
+'',
+getenv('USERS_DB_FILE') ?: USERS_DB_FILE,
+'',
+'');
 
 $template = Automatic comment from GIT on behalf of %s
 Revision: http://git.php.net/%s



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: hooks/post-receive.bugsweb

2012-03-18 Thread David Soria Parra
Commit: dcfc507197f7dfbe260cbd5ad6ce01697194676e
Author: David Soria Parra(d...@php.net) Sun, 18 Mar 2012 21:13:37 +0100
Committer: David Soria Parra(d...@php.net)  Sun, 18 Mar 2012 21:17:46 +0100
Parents: b6951f77158b0e27b2f13ebd42475c409c0e7861

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=dcfc507197f7dfbe260cbd5ad6ce01697194676e

Log:
Call the constructor correct

Changed paths:
  M  hooks/post-receive.bugsweb


Diff:
dcfc507197f7dfbe260cbd5ad6ce01697194676e
diff --git a/hooks/post-receive.bugsweb b/hooks/post-receive.bugsweb
index 39e6f9c..9ab2bc3 100755
--- a/hooks/post-receive.bugsweb
+++ b/hooks/post-receive.bugsweb
@@ -5,6 +5,7 @@ namespace Karma;
 const KARMA_FILE = '/git/checkout/SVNROOT/global_avail';
 const REPOSITORY_PATH = '/git/repositories';
 const LIB_PATH = '/git/checkout/karma/lib';
+const USERS_DB_FILE = '/git/users.db';
 
 set_include_path(
 getenv('KARMA_LIB_PATH') ?: LIB_PATH .
@@ -16,8 +17,24 @@ include 'Git/PushInformation.php';
 include 'Git/ReceiveHook.php';
 include 'Git/PostReceiveHook.php';
 
+$recipients = exec('git config hooks.mailinglist');
+$emailPrefix = exec('git config hooks.emailprefix') ?: '[git]';
+
+$user = null;
+if (getenv('REMOTE_USER')) {
+$user = getenv('REMOTE_USER');
+} else if (getenv('SSH_CONNECTION')  getenv('GL_USER')) {
+/* gitolite user */
+$user = getenv('GL_USER');
+}
+
 $hook = new \Git\PostReceiveHook(KARMA_FILE, REPOSITORY_PATH);
-$rpath = $hook-getReceivedMessages();
+$rpath = $hook-getReceivedMessages(
+getenv('GL_REPO_BASE_ABS') ?: REPOSITORY_PATH,
+$user,
+getenv('USERS_DB_FILE') ?: USERS_DB_FILE,
+$recipients,
+$emailPrefix);
 
 $template = Automatic comment from GIT on behalf of %s
 Revision: http://git.php.net/%s



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: hooks/post-receive

2012-03-18 Thread David Soria Parra
Commit: 3162a39a2c0068c7ad0d718df30599a660d3bd2b
Author: David Soria Parra(d...@php.net) Sun, 18 Mar 2012 21:21:18 +0100
Committer: David Soria Parra(d...@php.net)  Sun, 18 Mar 2012 21:21:18 +0100
Parents: dcfc507197f7dfbe260cbd5ad6ce01697194676e

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=3162a39a2c0068c7ad0d718df30599a660d3bd2b

Log:
Disable bugsweb for a moment

Changed paths:
  M  hooks/post-receive


Diff:
3162a39a2c0068c7ad0d718df30599a660d3bd2b
diff --git a/hooks/post-receive b/hooks/post-receive
index 2016acb..a27808f 100755
--- a/hooks/post-receive
+++ b/hooks/post-receive
@@ -1,4 +1,4 @@
 #!/bin/sh
 [ -f 'hooks/post-receive.mail' ] hooks/post-receive.mail
-[ -f 'hooks/post-receive.bugsweb' ]  hooks/post-receive.bugsweb
+# [ -f 'hooks/post-receive.bugsweb' ]  hooks/post-receive.bugsweb
 [ -f 'hooks/post-receive.mirror' ]   hooks/post-receive.mirror



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] [git][commit] karma.git: lib/Git/PostReceiveHook.php

2012-03-18 Thread David Soria Parra
Commit: db438a4a9ec117fec2767de6a0f79147d48285cc
Author: David Soria Parra(d...@php.net) Sun, 18 Mar 2012 21:22:53 +0100
Committer: David Soria Parra(d...@php.net)  Sun, 18 Mar 2012 21:22:53 +0100
Parents: 3162a39a2c0068c7ad0d718df30599a660d3bd2b

Link: 
http://git.php.net/?p=karma.git;a=commitdiff;h=db438a4a9ec117fec2767de6a0f79147d48285cc

Log:
Less square brackets

Changed paths:
  M  lib/Git/PostReceiveHook.php


Diff:
db438a4a9ec117fec2767de6a0f79147d48285cc
diff --git a/lib/Git/PostReceiveHook.php b/lib/Git/PostReceiveHook.php
index 5e28dee..15487ca 100644
--- a/lib/Git/PostReceiveHook.php
+++ b/lib/Git/PostReceiveHook.php
@@ -226,7 +226,7 @@ class PostReceiveHook extends ReceiveHook
 
 
 $mail = new \Mail();
-$mail-setSubject($this-emailPrefix . '[branch] ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);
+$mail-setSubject($this-emailPrefix . ' branch ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' branch ' . 
$shortname);
 
 $message = 'Branch ' . $shortname . ' in ' . 
$this-getRepositoryName() . ' was ' . $status[$changeType] . 'd' . \n;
 $message .= 'Date: ' . date('r') . \n;
@@ -320,7 +320,7 @@ class PostReceiveHook extends ReceiveHook
 $status = [self::TYPE_UPDATED = 'update', self::TYPE_CREATED = 
'create', self::TYPE_DELETED = 'delete'];
 $shortname = str_replace('refs/tags/', '', $name);
 $mail = new \Mail();
-$mail-setSubject($this-emailPrefix . '[tag] ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' tag ' . 
$shortname);
+$mail-setSubject($this-emailPrefix . 'tag ' . 
$this-getRepositoryName() . ': ' . $status[$changeType] . ' tag ' . 
$shortname);
 
 $message = 'Tag ' . $shortname . ' in ' . $this-getRepositoryName() . 
' was ' . $status[$changeType] . 'd' .
 (($changeType != self::TYPE_CREATED) ? ' from ' . $oldrev : '' ) . 
\n;
@@ -562,7 +562,7 @@ class PostReceiveHook extends ReceiveHook
 $diff =  \Git::gitExec('diff-tree -c -p %s', 
escapeshellarg($revision));
 
 $mail = new \Mail();
-$mail-setSubject($this-emailPrefix . '[commit] ' . 
$this-getRepositoryName() . ': ' . implode(' ', array_keys($paths)));
+$mail-setSubject($this-emailPrefix . ' commit ' . 
$this-getRepositoryName() . ': ' . implode(' ', array_keys($paths)));
 
 $message = '';
 



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php