mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
Address review: robust SHA parse + accurate dispatch doc
Parse '/evaluate <sha>' from issue comments with a bash regex instead of a sed BRE, avoiding word-boundary escape ambiguity across sed implementations and matching the validation used elsewhere in the gate. Reject over-length hex strings to the guidance path (fail-safe). Clarify the workflow_dispatch docs: the PR head travels in the head_sha input, while a dispatched run's github.sha is the default-branch tip. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 29ef3316-14f6-4dc1-a838-40f8be09f915
This commit is contained in:
@@ -387,7 +387,12 @@ jobs:
|
||||
issue_comment)
|
||||
# Require an explicit SHA: "/evaluate <7-40 hex>". The issue_comment
|
||||
# payload carries no commit id, so a bare /evaluate cannot be bound.
|
||||
REQUESTED="$(printf '%s' "$COMMENT_BODY" | sed -n '1{s/[[:cntrl:]]//g;s#^[[:space:]]*/evaluate[[:space:]]\{1,\}\([0-9a-fA-F]\{7,40\}\)\b.*#\1#p}')"
|
||||
# Parse with a bash regex (portable; avoids sed word-boundary quirks).
|
||||
FIRST_LINE="${COMMENT_BODY%%$'\n'*}" # first line only
|
||||
FIRST_LINE="${FIRST_LINE//$'\r'/}" # strip trailing CR
|
||||
if [[ "$FIRST_LINE" =~ ^[[:space:]]*/evaluate[[:space:]]+([0-9a-fA-F]{7,40})([^0-9a-fA-F]|$) ]]; then
|
||||
REQUESTED="${BASH_REMATCH[1]}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -53,11 +53,13 @@ runs the exact commit the maintainer approved:
|
||||
worker runs as `github-actions[bot]`, and label events emitted by
|
||||
`GITHUB_TOKEN` do **not** start workflows (GitHub's recursion guard), so the
|
||||
bot cannot use entry point 3. `workflow_dispatch` is exempt from that guard,
|
||||
so the worker dispatches `evaluation.yml` directly. A dispatched run's
|
||||
`head_sha` is the default branch (not the PR head), so the worker matches the
|
||||
run by `evaluation.yml`'s run name (`Evaluate PR #<n> @ <sha7>`) for
|
||||
idempotency. The gate resolves the worker's short `head_sha` input to that
|
||||
exact commit (it does not re-read the live PR head).
|
||||
so the worker dispatches `evaluation.yml` directly. A dispatched run checks
|
||||
out the default branch by default (`github.sha` is `main`'s tip, **not** the
|
||||
PR head) and its metadata doesn't record the target PR, so the worker matches
|
||||
the run by `evaluation.yml`'s run name (`Evaluate PR #<n> @ <sha7>`) for
|
||||
idempotency. The PR's head travels in the `head_sha` **input**, and the gate
|
||||
resolves that short SHA to the exact commit (it does not re-read the live PR
|
||||
head).
|
||||
|
||||
## State machine (worker)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user