fix(git): enhance error handling for missing branch information during deployment

This commit is contained in:
Andras Bacsai 2025-09-30 12:23:04 +02:00
parent 8e7c869d23
commit 9b4abe753d

View file

@ -1677,7 +1677,23 @@ private function check_git_if_build_needed()
);
}
if ($this->saved_outputs->get('git_commit_sha') && ! $this->rollback) {
$this->commit = $this->saved_outputs->get('git_commit_sha')->before("\t");
$output = $this->saved_outputs->get('git_commit_sha');
if ($output->isEmpty() || ! str($output)->contains("\t")) {
$errorMessage = "Failed to find branch '{$local_branch}' in repository.\n\n";
$errorMessage .= "Please verify:\n";
$errorMessage .= "- The branch name is correct\n";
$errorMessage .= "- The branch exists in the repository\n";
$errorMessage .= "- You have access to the repository\n";
if ($this->pull_request_id !== 0) {
$errorMessage .= "- The pull request #{$this->pull_request_id} exists and is accessible\n";
}
throw new \RuntimeException($errorMessage);
}
$this->commit = $output->before("\t");
$this->application_deployment_queue->commit = $this->commit;
$this->application_deployment_queue->save();
}