Skip to content

Commit

Permalink
Passes repo.root into filterFileListByFileSet target (#446)
Browse files Browse the repository at this point in the history
filterFileListByFileSet was producing erroneous file paths when determining which files to sniff.
  • Loading branch information
steveworley authored and grasmash committed Sep 23, 2016
1 parent 9032489 commit cb00764
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 28 additions & 1 deletion phing/phingcludes/FilterFileListByFileSetTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class FilterFileListByFileSetTask extends Task {
*/
protected $return_property = null;

/**
* The project root directory.
*
* @var string
*/
protected $root;

public function setFileList($fileList)
{
$this->fileList = $fileList;
Expand Down Expand Up @@ -50,6 +57,16 @@ public function setReturnProperty($str)
$this->return_property = $str;
}

/**
* Project root directory.
*
* @param string $root The project root.
* @return void
*/
public function setRoot($root)
{
$this->root = $root;
}

/**
* The main entry point method.
Expand Down Expand Up @@ -80,8 +97,18 @@ public function main() {
return (bool) $filteredList;
}

/**
* Convert given relative paths to absolute file paths.
*
* @param string $relative_path A relative file path.
*
* @return string
* Absolute file path.
*/
protected function prependProjectPath($relative_path) {
return $this->project->getBasedir()->getAbsolutePath() . DIRECTORY_SEPARATOR . $relative_path;
return isset($this->root)
? $this->root . DIRECTORY_SEPARATOR . $relative_path
: $this->project->getBasedir()->getAbsolutePath() . DIRECTORY_SEPARATOR . $relative_path;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion phing/tasks/validate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<fail unless="files" message="Missing files parameter."/>
<property name="phpcs.ruleset" value="${repo.root}/vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml"/>

<filterFileListByFileSet fileList="${files}" returnProperty="filteredFileList">
<filterFileListByFileSet fileList="${files}" root="${repo.root}" returnProperty="filteredFileList">
<fileset refid="files.php.custom.modules"/>
<fileset refid="files.php.custom.themes"/>
<fileset refid="files.php.tests"/>
Expand Down

0 comments on commit cb00764

Please sign in to comment.