Skip to content
Browse files

Add paths arguments from Git rev-list

  • Loading branch information...
1 parent 28f8b3c commit f943acc67588049c9a5502bff5e8ca80abf6e4ad @chEbba committed May 3, 2011
Showing with 34 additions and 4 deletions.
  1. +34 −4 VersionControl/Git/Util/RevListFetcher.php
View
38 VersionControl/Git/Util/RevListFetcher.php
@@ -30,6 +30,7 @@
* @category VersionControl
* @package VersionControl_Git
* @author Kousuke Ebihara <ebihara@php.net>
+ * @author Kirill chEbba Chebunin <iam@chebba.org>
* @copyright 2010 Kousuke Ebihara
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
*/
@@ -50,6 +51,13 @@ class VersionControl_Git_Util_RevListFetcher extends VersionControl_Git_Util_Com
protected $target = self::DEFAULT_TARGET;
/**
+ * Commits will be filtered by modifications for this paths only
+ *
+ * @var type
+ */
+ protected $paths = array();
+
+ /**
* Set the target
*
* @param string $target The target for the commits that you want to get
@@ -64,6 +72,20 @@ public function target($target)
}
/**
+ * Set paths
+ *
+ * @param array $paths The array of paths which commits you want
+ *
+ * @return VersionControl_Git_Util_RevListFetcher The "$this" object
+ */
+ public function paths(array $paths)
+ {
+ $this->paths = $paths;
+
+ return $this;
+ }
+
+ /**
* Reset properties
*
* @return VersionControl_Git_Util_RevListFetcher The "$this" object
@@ -74,6 +96,8 @@ public function reset()
$this->target = self::DEFAULT_TARGET;
+ $this->paths = array();
+
return $this;
}
@@ -84,10 +108,16 @@ public function reset()
*/
public function fetch()
{
- $string = $this->setSubCommand('rev-list')
- ->setOption('pretty', 'raw')
- ->setArguments(array($this->target))
- ->execute();
+ $this->setSubCommand('rev-list')
+ ->setOption('pretty', 'raw')
+ ->setArguments(array($this->target));
+
+ // Add paths to arguments
+ foreach ($this->paths as $path) {
+ $this->addArgument($path);
+ }
+
+ $string = $this->execute();
$lines = explode("\n", $string);

0 comments on commit f943acc

Please sign in to comment.
Something went wrong with that request. Please try again.