Skip to content

Commit

Permalink
Added disabling of local exclude file.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored Feb 17, 2019
1 parent b89900a commit 4ecce56
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/ArtefactTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 4ecce56

Please sign in to comment.