gps 7.3.3

Official CLI & library for Git Patch Stack
Documentation
#!/bin/sh

# request_review_post_sync hook using GitHub CLI (https://cli.github.com)
#
# This hook handles requesting review after the sync step of the request review
# command has completed.
#
# In this particular case a pull request will be created within GitHub by using
# the GitHub CLI. If re-requesting a review the browser will open
# the associated pull request in the browser.
# Therefore, you need to make sure that you have the GitHub CLI
# installed, in your PATH, and have logged into it for this hook to work.
#
# Setup:
# > brew install gh
# > gh auth login

patch_upstream_branch_name=$1 # string of the patch's associated upstream branch name (e.g. ps/rr/your-patches-branch-name)
patch_stack_upstream_branch_name_relative_to_remote=$2 # string of the patch stack's branch name (e.g. main)
patch_stack_upstream_remote_name=$3 # string of the patch stack's remote name (e.g. origin)
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
  closed=$(gh pr -R "$patch_stack_upstream_remote_url" view $patch_upstream_branch_name --json closed --jq '.closed')
  if [ $closed != "true" ]; then
    exit 0
  else
    gh pr view "$patch_upstream_branch_name" --web  -R "$patch_stack_upstream_remote_url"
  fi
fi

gh pr create --assignee @me --fill --web --base "$patch_stack_upstream_branch_name_relative_to_remote" --head "$patch_upstream_branch_name" -R "$patch_stack_upstream_remote_url"