Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paths arguments from Git rev-list #11

Merged
merged 1 commit into from
Apr 21, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions VersionControl/Git/Util/RevListFetcher.php
Original file line number Diff line number Diff line change
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