[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.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 @@
+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: 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.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