feat: ensure current branch is master for release

This commit is contained in:
Phan An 2024-10-31 20:56:50 +07:00
parent a86c2ab654
commit d6053e931a

View file

@ -25,6 +25,7 @@ class ReleaseCommand extends Command
public function handle(): int
{
self::ensureMainBranch();
self::ensureCleanWorkingDirectory();
$this->getCurrentVersion();
@ -134,6 +135,17 @@ class ReleaseCommand extends Command
note('Current version: ' . $this->currentVersion->prefix());
}
private static function ensureMainBranch(): void
{
$branch = trim(Process::run('git branch --show-current')->output());
if ($branch !== 'master') {
error("You must be on the master branch to release a new version (Current branch: '$branch.')");
exit(self::FAILURE);
}
}
private static function ensureCleanWorkingDirectory(): void
{
if (Process::run('git status --porcelain')->output()) {