From 354231356d0e6ce3ba73a059c68467e89c39a835 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 2 Nov 2010 19:33:54 +0100 Subject: [PATCH] Actually use the gitignore information. --- .../Components/Pear/Package/Contents/Ignore.php | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/lib/Components/Pear/Package/Contents/Ignore.php b/components/lib/Components/Pear/Package/Contents/Ignore.php index 50118a3c4..9bf48e19a 100644 --- a/components/lib/Components/Pear/Package/Contents/Ignore.php +++ b/components/lib/Components/Pear/Package/Contents/Ignore.php @@ -52,6 +52,7 @@ class Components_Pear_Package_Contents_Ignore public function __construct($gitignore, $base = '') { $this->_base = $base; + $this->_prepare($gitignore); } /** @@ -98,6 +99,28 @@ class Components_Pear_Package_Contents_Ignore } /** + * Prepare the list of ignores and include from the gitignore input. + * + * @param string $gitignore + * + * @return NULL + */ + private function _prepare($gitignore) + { + foreach (split("\n", $gitignore) as $line) { + $line = strtr($line, ' ', ''); + if (empty($line) || strpos($line, '#') == 1) { + continue; + } + if (strpos($line, '!') == 1) { + $this->_include[] = $this->_getRegExpableSearchString($line); + } else { + $this->_ignore[] = $this->_getRegExpableSearchString($line); + } + } + } + + /** * Converts $s into a string that can be used with preg_match * * @param string $s string with wildcards ? and * -- 2.11.0