Skip to content

Commit

Permalink
Add paths arguments from Git rev-list
Browse files Browse the repository at this point in the history
  • Loading branch information
chEbba committed May 3, 2011
1 parent 28f8b3c commit f943acc
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions VersionControl/Git/Util/RevListFetcher.php
Expand Up @@ -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
*/
Expand All @@ -49,6 +50,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
*
Expand All @@ -63,6 +71,20 @@ public function target($target)
return $this;
}

/**
* 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
*
Expand All @@ -74,6 +96,8 @@ public function reset()

$this->target = self::DEFAULT_TARGET;

$this->paths = array();

return $this;
}

Expand All @@ -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);

Expand Down

0 comments on commit f943acc

Please sign in to comment.