-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Output commit SHA when gh pr merge is successful #10746
Copy link
Copy link
Open
Labels
enhancementa request to improve CLIa request to improve CLIgh-prrelating to the gh pr commandrelating to the gh pr command
Description
Describe the feature or problem you’d like to solve
Currently there seems to be no way to get SHA of the resulting commit when landing a PR without falling back to a "manual" call.
Proposed solution
Add support for a flag that would allow users opt-in (or opt-out) of getting the commit SHA in the stdout.
Additional context
Currently here's what we use:
jq -n \
--arg title "${commit_title}" \
--arg body "${commit_body}" \
--arg head "${commit_head}" \
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
cat output.json
if ! commit="$(gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input output.json --jq 'if .merged then .sha else halt_error end')"; then
pr_merge_failed "$pr" # Handle the failed merger
fi
# Use the final commit SHA
gh pr comment "$pr" --body "Landed in $commit"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementa request to improve CLIa request to improve CLIgh-prrelating to the gh pr commandrelating to the gh pr command
Type
Fields
Give feedbackNo fields configured for issues without a type.