Output commit SHA when `gh pr merge` is successful
- Dominant language
- Go
- Stars
- 46.3k
- Forks
- 9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 89
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:
```sh
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"
```
Contributor guide
Assessment
This issue has not been assessed yet.