From: Gunnar Wrobel Date: Tue, 2 Nov 2010 18:33:54 +0000 (+0100) Subject: Actually use the gitignore information. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=354231356d0e6ce3ba73a059c68467e89c39a835;p=horde.git Actually use the gitignore information. --- 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 *