Skip to content

Commit

Permalink
Merge pull request #328 from spryker-sdk/bugfix/frw-9570/fixed-invali…
Browse files Browse the repository at this point in the history
…d-base-branched

FRW-9570 Set Base branch from `BUDDY_RUN_BRANCH` var.
  • Loading branch information
asmarovydlo authored Dec 16, 2024
2 parents d983797 + e11c3aa commit 3929a52
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/Upgrade/Infrastructure/Configuration/ConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@ public function getCiExecutionId(): string
return (string)getenv('CI_EXECUTION_ID');
}

/**
* Specification:
* - Defines Buddy run branch.
*
* @return string
*/
public function getBuddyRunBranch(): string
{
return (string)getenv('BUDDY_RUN_BRANCH');
}

/**
* Specification:
* - Defines ci workspace name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function __construct(
*/
public function send(ReportDto $reportDto): void
{
if (!$this->configurationProvider->isReportingEnabled()) {
return;
}

$this->httpClient->request(
'POST',
$this->endpointUrl,
Expand Down
15 changes: 12 additions & 3 deletions src/Upgrade/Infrastructure/VersionControlSystem/Git/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,23 @@ protected function getHeadBranch(): string
protected function getBaseBranch(): string
{
if ($this->baseBranch === '') {
$command = ['git', 'rev-parse', '--abbrev-ref', 'HEAD'];
$process = $this->processRunner->run($command);
$this->baseBranch = trim($process->getOutput());
$this->baseBranch = $this->configurationProvider->getBuddyRunBranch() ?: $this->getCurrentBranch();
}

return $this->baseBranch;
}

/**
* @return string
*/
protected function getCurrentBranch(): string
{
$command = ['git', 'rev-parse', '--abbrev-ref', 'HEAD'];
$process = $this->processRunner->run($command);

return trim($process->getOutput());
}

/**
* @param \Upgrade\Application\Dto\StepsResponseDto $stepsExecutionDto
* @param array<string> $command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public function testSendReport(): void
->method('getReportSendAuthToken')
->willReturn('your_auth_token');

$configurationProvider->expects($this->once())
->method('isReportingEnabled')
->willReturn(true);

// Configure the http client mock
$httpClient->expects($this->once())
->method('request')
Expand Down

0 comments on commit 3929a52

Please sign in to comment.