From 4ecce56f6c07c59241c6b9e763afd67978db1a78 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 18 Feb 2019 01:24:23 +1100 Subject: [PATCH] Added disabling of local exclude file. --- src/ArtefactTrait.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/ArtefactTrait.php b/src/ArtefactTrait.php index a474345..1bf3635 100644 --- a/src/ArtefactTrait.php +++ b/src/ArtefactTrait.php @@ -199,6 +199,7 @@ protected function prepareArtefact() if (!empty($this->gitignoreFile)) { $this->replaceGitignore($this->gitignoreFile, $this->src); + $this->disableLocalExclude($this->src); $this->removeExcludedFiles($this->src); } @@ -216,6 +217,7 @@ protected function prepareArtefact() */ protected function cleanup() { + $this->restoreLocalExclude($this->src); $this->gitSwitchToBranch($this->src, $this->originalBranch); $this->gitRemoveBranch($this->src, $this->artefactBranch); $this->gitRemoveRemote($this->src, $this->remoteName); @@ -495,6 +497,38 @@ protected function replaceGitignore($filename, $path) $this->fsFileSystem->remove($filename); } + /** + * Disable local exclude file (.git/info/exclude). + * + * @param string $path + * Path to repository. + */ + protected function disableLocalExclude($path) + { + $filename = $path.DIRECTORY_SEPARATOR.'.git'.DIRECTORY_SEPARATOR.'info'.DIRECTORY_SEPARATOR.'exclude'; + $filenameDisabled = $filename.'.bak'; + if ($this->fsFileSystem->exists($filename)) { + $this->say('Disabling local exclude'); + $this->fsFileSystem->rename($filename, $filenameDisabled); + } + } + + /** + * Restore previously disabled local exclude file. + * + * @param string $path + * Path to repository. + */ + protected function restoreLocalExclude($path) + { + $filename = $path.DIRECTORY_SEPARATOR.'.git'.DIRECTORY_SEPARATOR.'info'.DIRECTORY_SEPARATOR.'exclude'; + $filenameDisabled = $filename.'.bak'; + if ($this->fsFileSystem->exists($filenameDisabled)) { + $this->say('Restoring local exclude'); + $this->fsFileSystem->rename($filenameDisabled, $filename); + } + } + /** * Remove excluded files. *