Skip to content

Commit b4643da

Browse files
Handle truncated hashes
1 parent ee23aee commit b4643da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Commands/Workflow/WaitCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ protected function waitForCommit(
196196
$end_time = 0;
197197
}
198198

199-
// Validate commit SHA format
200-
if (!preg_match('/^[0-9a-f]{40}$/', $target_commit)) {
199+
// Validate commit SHA format (allow shortened hashes of 7+ characters)
200+
if (!preg_match('/^[0-9a-f]{7,40}$/', $target_commit)) {
201201
throw new TerminusException(
202-
'Commit {commit} is not a valid commit SHA.',
202+
'Commit {commit} is not a valid commit SHA (must be 7-40 hexadecimal characters).',
203203
['commit' => $target_commit]
204204
);
205205
}
@@ -237,8 +237,8 @@ protected function waitForCommit(
237237
foreach ($workflow_logs as $log) {
238238
// Check if this workflow is for the target environment
239239
if (isset($log->workflow->environment) && $log->workflow->environment === $env_name) {
240-
// Check if this workflow has the target commit
241-
if (isset($log->workflow->target_commit) && $log->workflow->target_commit === $target_commit) {
240+
// Check if this workflow has the target commit (support shortened hashes)
241+
if (isset($log->workflow->target_commit) && strpos($log->workflow->target_commit, $target_commit) === 0) {
242242
// Check if workflow started after our start time
243243
if (isset($log->workflow->started_at) && $log->workflow->started_at >= $startTime) {
244244
$matching_workflows[] = $log;

0 commit comments

Comments
 (0)