diff --git a/src/ArtefactTrait.php b/src/ArtefactTrait.php index 90161bb..7b486d4 100644 --- a/src/ArtefactTrait.php +++ b/src/ArtefactTrait.php @@ -556,7 +556,7 @@ protected function restoreLocalExclude($path) */ protected function removeExcludedFiles($location, $gitignore = '.gitignore') { - $command = sprintf('ls-files --directory --i --exclude-from=%s %s', $location.DIRECTORY_SEPARATOR.$gitignore, $location); + $command = sprintf('ls-files --directory -i --exclude-from=%s %s', $location.DIRECTORY_SEPARATOR.$gitignore, $location); $result = $this->gitCommandRun($location, $command, 'Unable to remove excluded files'); $excludedFiles = array_filter(preg_split('/\R/', $result->getMessage())); foreach ($excludedFiles as $excludedFile) { diff --git a/tests/ForcePushTest.php b/tests/ForcePushTest.php index 0b95d44..d3f5f2f 100644 --- a/tests/ForcePushTest.php +++ b/tests/ForcePushTest.php @@ -91,43 +91,49 @@ public function testGitignore() public function testGitignoreCustom() { - $this->gitCreateFixtureFile($this->src, 'mygitignore', '3.txt'); $this->gitCreateFixtureCommits(2); - $this->gitCreateFixtureFile($this->src, '3.txt'); + $this->gitCreateFixtureFile($this->src, 'uncom_ignored_com.txt'); + $this->gitCreateFixtureFile($this->src, 'mygitignore', 'uncom_ignored_com.txt'); $this->assertBuildSuccess('--gitignore='.$this->src.DIRECTORY_SEPARATOR.'mygitignore'); $this->assertFixtureCommits(2, $this->dst, 'testbranch', ['Deployment commit']); - $this->gitAssertFilesNotExist($this->dst, '3.txt'); + $this->gitAssertFilesNotExist($this->dst, 'uncom_ignored_com.txt'); // Now, remove the .gitignore and push again. $this->gitRemoveFixtureFile($this->src, 'mygitignore'); $this->gitCommitAll($this->src, 'Commit number 3'); $this->assertBuildSuccess(); - $this->assertFixtureCommits(3, $this->dst, 'testbranch', ['Deployment commit']); + + $this->assertFixtureCommits(3, $this->dst, 'testbranch', ['Deployment commit'], false); + $this->gitAssertFilesCommitted($this->dst, ['1.txt', '2.txt', 'uncom_ignored_com.txt'], 'testbranch'); + $this->gitAssertFilesExist($this->dst, ['1.txt', '2.txt', 'uncom_ignored_com.txt'], 'testbranch'); } public function testGitignoreCustomRemoveCommittedFiles() { - $this->gitCreateFixtureFile($this->src, '.gitignore', ['3.txt']); - $this->gitCreateFixtureFile($this->src, '3.txt'); - $this->gitCreateFixtureFile($this->src, 'subdir/4.txt'); - $this->gitCreateFixtureFile($this->src, 'subdir/5.txt'); + $this->gitCreateFixtureFile($this->src, '.gitignore', ['ignored_ignored.txt', 'ignored_com.txt']); + + $this->gitCreateFixtureFile($this->src, 'ignored_ignored.txt'); + $this->gitCreateFixtureFile($this->src, 'ignored_com.txt'); + $this->gitCreateFixtureFile($this->src, 'subdir/com_com.txt'); + $this->gitCreateFixtureFile($this->src, 'subdir/com_ignored.txt'); $this->gitCreateFixtureCommits(2); $this->gitCommitAll($this->src, 'Custom third commit'); + $this->gitCreateFixtureFile($this->src, 'uncom_ignored.txt'); + $this->gitCreateFixtureFile($this->src, 'uncom_com.txt'); + $this->gitAssertFilesCommitted($this->src, ['1.txt', '2.txt', 'subdir/com_com.txt', 'subdir/com_ignored.txt']); + $this->gitAssertNoFilesCommitted($this->src, ['ignored_ignored.txt', 'ignored_com.txt', 'uncom_ignored.txt', 'uncom_com.txt']); - $this->gitAssertFilesCommitted($this->src, ['1.txt', '2.txt', 'subdir/4.txt', 'subdir/5.txt']); - $this->gitAssertNoFilesCommitted($this->src, ['3.txt']); - - $this->gitCreateFixtureFile($this->src, 'mygitignore', ['1.txt', '3.txt', '5.txt']); + $this->gitCreateFixtureFile($this->src, 'mygitignore', ['1.txt', 'ignored_ignored.txt', 'com_ignored.txt', 'uncom_ignored.txt']); $this->assertBuildSuccess('--gitignore='.$this->src.DIRECTORY_SEPARATOR.'mygitignore'); $this->assertFixtureCommits(2, $this->dst, 'testbranch', ['Custom third commit', 'Deployment commit'], false); - $this->gitAssertFilesCommitted($this->dst, ['2.txt', 'subdir/4.txt'], 'testbranch'); - $this->gitAssertNoFilesCommitted($this->dst, ['1.txt', '3.txt', 'subdir/5.txt'], 'testbranch'); - $this->gitAssertFilesExist($this->dst, ['2.txt', 'subdir/4.txt'], 'testbranch'); - $this->gitAssertFilesNotExist($this->dst, ['1.txt', '3.txt', 'subdir/5.txt'], 'testbranch'); + $this->gitAssertFilesCommitted($this->dst, ['2.txt', 'ignored_com.txt', 'subdir/com_com.txt', 'uncom_com.txt'], 'testbranch'); + $this->gitAssertNoFilesCommitted($this->dst, ['1.txt', 'ignored_ignored.txt', 'subdir/com_ignored.txt', 'uncom_ignored.txt'], 'testbranch'); + $this->gitAssertFilesExist($this->dst, ['2.txt', 'ignored_com.txt', 'subdir/com_com.txt', 'uncom_com.txt'], 'testbranch'); + $this->gitAssertFilesNotExist($this->dst, ['1.txt', 'ignored_ignored.txt', 'subdir/com_ignored.txt', 'uncom_ignored.txt'], 'testbranch'); } public function testBuildTag()