From 2dcaf8fb5bca0df9ef8b27663daf401e000c1fde Mon Sep 17 00:00:00 2001 From: Martin Ambroz Date: Sat, 28 Mar 2015 11:13:12 +0400 Subject: [PATCH 1/2] Paths on Windows are rendered with backward slashes. --- src/MagentoHackathon/Composer/Magento/GitIgnore.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MagentoHackathon/Composer/Magento/GitIgnore.php b/src/MagentoHackathon/Composer/Magento/GitIgnore.php index cbe93485..46d7a666 100644 --- a/src/MagentoHackathon/Composer/Magento/GitIgnore.php +++ b/src/MagentoHackathon/Composer/Magento/GitIgnore.php @@ -40,6 +40,7 @@ public function __construct($fileLocation) */ public function addEntry($file) { + $file = str_replace(DIRECTORY_SEPARATOR, '/', $file); if (!isset($this->lines[$file])) { $this->lines[$file] = $file; } @@ -61,6 +62,7 @@ public function addMultipleEntries(array $files) */ public function removeEntry($file) { + $file = str_replace(DIRECTORY_SEPARATOR, '/', $file); if (isset($this->lines[$file])) { unset($this->lines[$file]); $this->hasChanges = true; From 6e8032f097b940d17bbc1110a9246e2b5b57093a Mon Sep 17 00:00:00 2001 From: Martin Ambroz Date: Sat, 15 Aug 2015 13:08:18 +0400 Subject: [PATCH 2/2] This resolves issue on Windows with .gitignore during development as the paths contain mixed slashes. --- .../Composer/Magento/GitIgnore.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/MagentoHackathon/Composer/Magento/GitIgnore.php b/src/MagentoHackathon/Composer/Magento/GitIgnore.php index d7390233..c0c749b0 100644 --- a/src/MagentoHackathon/Composer/Magento/GitIgnore.php +++ b/src/MagentoHackathon/Composer/Magento/GitIgnore.php @@ -41,7 +41,7 @@ public function __construct($fileLocation) public function addEntry($file) { $file = $this->prependSlashIfNotExist($file); - $file = str_replace(DIRECTORY_SEPARATOR, '/', $file); + $file = $this->normalizePath($file); if (!isset($this->lines[$file])) { $this->lines[$file] = $file; } @@ -64,7 +64,7 @@ public function addMultipleEntries(array $files) public function removeEntry($file) { $file = $this->prependSlashIfNotExist($file); - $file = str_replace(DIRECTORY_SEPARATOR, '/', $file); + $file = $this->normalizePath($file); if (isset($this->lines[$file])) { unset($this->lines[$file]); $this->hasChanges = true; @@ -110,4 +110,16 @@ private function prependSlashIfNotExist($file) { return sprintf('/%s', ltrim($file, '/')); } + + /** + * Normalizes paths to UNIX format + * + * @param string $file + * @return string + */ + private function normalizePath($file) + { + return str_replace(DIRECTORY_SEPARATOR, '/', $file); + } + }