[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: 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: 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