Skip to content

Commit

Permalink
SDK-5471: Fix composer issue behaviour (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyspryker authored Nov 13, 2023
1 parent ee67f49 commit 266660d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public function process(ReleaseGroupDtoCollection $requireRequestCollection, Ste
}

if (!$response->isSuccessful()) {
$stepsExecutionDto->setIsSuccessful(false);
$composerViolation = $this->composerViolationDtoFactory->createFromPackageManagerResponse($response);

$stepsExecutionDto->setError(
Expand Down
14 changes: 13 additions & 1 deletion src/Upgrade/Infrastructure/VersionControlSystem/Git/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function createPullRequest(StepsResponseDto $stepsExecutionDto): StepsRes
return $stepsExecutionDto;
}

if ($composerDiffDto === null) {
if (!$this->hasCurrentBranchCommits()) {
$this->createEmptyCommit($stepsExecutionDto, 'pr empty commit');
$this->push($stepsExecutionDto);
}
Expand Down Expand Up @@ -379,4 +379,16 @@ protected function prepareStepsExecutionDto(StepsResponseDto $stepsExecutionDto,

return $stepsExecutionDto;
}

/**
* @return bool
*/
protected function hasCurrentBranchCommits(): bool
{
$command = ['git', 'log', '--oneline', $this->getBaseBranch() . '..'];

$process = $this->processRunner->run($command);

return trim($process->getOutput()) !== '';
}
}
2 changes: 1 addition & 1 deletion src/Upgrader/Console/UpgraderConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function execute(InputInterface $input, OutputInterface $output): int

$output->writeln((string)$stepsExecutionDto->getOutputMessage());

if (!$stepsExecutionDto->getIsSuccessful()) {
if (!$stepsExecutionDto->getIsSuccessful() || $stepsExecutionDto->hasBlockers()) {
return Command::FAILURE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function testRunWithSequentialReleaseGroupProcessorPackageManagerError():
$stepsResponseDto = $step->run($stepsResponseDto);

// Assert
$this->assertFalse($stepsResponseDto->isSuccessful());
$this->assertTrue($stepsResponseDto->isSuccessful());
$this->assertSame(
<<<OUT
Amount of available release groups for the project: 2
Expand Down

0 comments on commit 266660d

Please sign in to comment.