Skip to content

Commit e7506e1

Browse files
author
Jonathan Visser
committed
Add additional checks for git changes in release notes
1 parent e3bd6da commit e7506e1

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/Deployer/TaskBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public function buildAll(array $commands, string $namePrefix): array
4141
}
4242

4343
/**
44-
* @param TaskConfigurationInterface $command
44+
* @param Command $command
4545
* @param string $name
4646
* @return Task
4747
* @throws \Exception
4848
*/
49-
private function build(TaskConfigurationInterface $command, string $name): Task
49+
private function build(Command $command, string $name): Task
5050
{
5151
$task = task($name, function () use ($command) {
5252
$this->runCommandWithin($command);

src/Stdlib/ReleaseInfo.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Hypernode\Deploy\Stdlib;
44

55
use Hypernode\DeployConfiguration\Stage;
6+
use Deployer\Exception\RunException;
67

78
use function Deployer\get;
89
use function Deployer\parse;
@@ -18,7 +19,12 @@ class ReleaseInfo
1819

1920
public function getCommitSha(): string
2021
{
21-
return runLocally('git rev-parse HEAD');
22+
try {
23+
return runLocally('git rev-parse HEAD');
24+
}
25+
catch (\Throwable $e) {
26+
return '';
27+
}
2228
}
2329

2430
public function getMessage(): string
@@ -52,7 +58,11 @@ public function getMessage(): string
5258
*/
5359
private function branchList(): array
5460
{
55-
$gitLogOutput = runLocally('git log --merges -n 1');
61+
$gitLogOutput = '';
62+
try {
63+
$gitLogOutput = runLocally('git log --merges -n 1');
64+
}
65+
catch (RunException $e) {}
5666

5767
if (!preg_match(self::MERGE_PATTERN, $gitLogOutput, $matches)) {
5868
output()->write('No merge commit found');

0 commit comments

Comments
 (0)