Skip to content

Commit

Permalink
SDK-5690: Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vol4onok committed Dec 14, 2023
1 parent 1a4f2ea commit 0bd3e8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
12 changes: 8 additions & 4 deletions src/IntegratorLock/IntegratorLockCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,24 @@ public function deleteLock(): void
{
$lockFilePath = $this->config->getIntegratorLockFilePath();

if ($this->isLockFileIgnoredByGit($lockFilePath) && !$this->filesystem->exists($lockFilePath)) {
if ($this->isLockFileIgnoredByGit($lockFilePath)) {
return;
}
$gitAddCommand = ['git', 'add'];
if ($this->filesystem->exists($lockFilePath)) {
$this->filesystem->remove($lockFilePath);
$gitAddCommand[] = $lockFilePath;
}
$gitignorePath = $this->config->getProjectRootDirectory() . static::GITIGNORE_FILE;

if (!$this->filesystem->exists($gitignorePath) || strpos((string)file_get_contents($gitignorePath), $this->config::INTEGRATOR_LOCK) === false) {
$this->filesystem->appendToFile($gitignorePath, PHP_EOL . $this->config::INTEGRATOR_LOCK . PHP_EOL);
$gitAddCommand[] = $gitignorePath;

Check warning on line 69 in src/IntegratorLock/IntegratorLockCleaner.php

View check run for this annotation

Codecov / codecov/patch

src/IntegratorLock/IntegratorLockCleaner.php#L68-L69

Added lines #L68 - L69 were not covered by tests
}
if (count($gitAddCommand) > 2) {
$this->processExecutor->execute($gitAddCommand);
$this->processExecutor->execute(['git', 'commit', '-m', sprintf('Removed `%s` file.', $this->config::INTEGRATOR_LOCK), '-n']);
}

$this->processExecutor->execute(['git', 'add', $lockFilePath, $gitignorePath]);
$this->processExecutor->execute(['git', 'commit', '-m', sprintf('Removed `%s` file.', $this->config::INTEGRATOR_LOCK), '-n']);
}

/**
Expand Down
18 changes: 0 additions & 18 deletions tests/SprykerSdkTest/Integrator/IntegratorFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,22 +561,4 @@ public function testRunUpdateLock(): void

$this->assertNotEmpty(trim(file_get_contents($integratorLock)));
}

/**
* @return void
*/
public function testRunCleanLock(): void
{
// Arrange
$ioAdapter = $this->buildSymfonyConsoleInputOutputAdapter();

file_put_contents($this->getTestTmpDirPath() . '/integrator.lock', 'test');

// Act
$this->createIntegratorFacade()->runCleanLock($ioAdapter);

// Assert
$integratorLock = $this->getTestTmpDirPath() . '/integrator.lock';
$this->assertFileDoesNotExist($integratorLock);
}
}

0 comments on commit 0bd3e8b

Please sign in to comment.