Skip to content

Commit

Permalink
Improve example request_review_post_sync hook
Browse files Browse the repository at this point in the history
Improve example request_review_post_sync hook so that it handles a
failure case better and so that it lets the user know more about what is
going on.

<!-- ps-id: 366f0ee9-4d8c-4c0e-9638-80137fa3883c -->

Signed-off-by: Drew De Ponte <[email protected]>
  • Loading branch information
drewdeponte committed Oct 19, 2023
1 parent 8db2fa8 commit 294f036
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions example_hooks/request_review_post_sync-github-cli-example
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ patch_stack_upstream_remote_url=$4 # string of the patch stack's remote url

gh pr -R "$patch_stack_upstream_remote_url" view $patch_upstream_branch_name
if [ $? -eq 0 ]; then
echo "gh pr -R \"$patch_stack_upstream_remote_url\" view $patch_upstream_branch_name succeded"

closed=$(gh pr -R "$patch_stack_upstream_remote_url" view $patch_upstream_branch_name --json closed --jq '.closed')
if [ $closed != "true" ]; then
exit 0
if [ $? -eq 0 ]; then
echo "gh pr -R \"$patch_stack_upstream_remote_url\" view $patch_upstream_branch_name --json closed --jq '.closed' succeded"
echo "closed=$closed"
if [ $closed != "true" ]; then
echo "An open PR was found for the branch, so exiting to prevent duplicate PR creation."
exit 0
fi
fi
fi

Expand Down

0 comments on commit 294f036

Please sign in to comment.