fix(api): match request branch with wildcard for owner approval check

The owner approval file is on request/tag-V1R3C0-self-loop-autonomous-engine
but the code was looking for request/tag-V1R3C0 (branch name not derivable
from version alone). Now uses glob pattern request/tag-{ver}* to find
the correct branch.
This commit is contained in:
2026-07-08 14:08:00 +08:00
parent ba35d0ccfe
commit 1d4016a517
+29 -10
View File
@@ -256,19 +256,38 @@ class H(BaseHTTPRequestHandler):
self.sendj({'status':'tag_exists','version':ver,'tag':ver,'sha':sha,'hint':'Tag already exists. No action needed.'})
return
# Check if owner approval exists on the request branch
# Check if owner approval exists - search multiple branch patterns
owner_approval_path = f'baseline/promotions/{safe(ver)}.owner-approved.json'
owner_approved = False
approve_candidates = []
if BARE_REPO.exists():
try:
sh(['--git-dir',str(BARE_REPO),'cat-file','-e',f'request/tag-{safe(ver)}:{owner_approval_path}'], True)
owner_approved = True
except RuntimeError:
pass
else:
ov = (WS / owner_approval_path)
if ov.exists() and ov.is_file():
owner_approved = True
# Look for a request branch matching this version
branches = sh(['--git-dir',str(BARE_REPO),'branch','--list',f'request/tag-{safe(ver)}*'])
for b in (branches['stdout'] or '').splitlines():
b = b.strip().lstrip('*').strip()
if b:
approve_candidates.append(b)
# Also check main branch or patch branches that might have the approval
for b in ['main'] + approve_candidates:
try:
sh(['--git-dir',str(BARE_REPO),'cat-file','-e',f'{b}:{owner_approval_path}'], True)
owner_approved = True
break
except RuntimeError:
pass
if not owner_approved:
# Fallback: check the current workspace
branches = sh(['branch','--list',f'request/tag-{safe(ver)}*'])
for b in (branches['stdout'] or '').splitlines():
b = b.strip().lstrip('*').strip()
approve_candidates.append(b)
for b in ['main'] + approve_candidates:
try:
sh(['cat-file','-e',f'{b}:{owner_approval_path}'])
owner_approved = True
break
except RuntimeError:
pass
if data.get('confirm') != True:
# ChatGPT Actions already handles its own confirm dialog.