patch_upstream_branch_name=$1 patch_stack_upstream_branch_name_relative_to_remote=$2 patch_stack_upstream_remote_name=$3 patch_stack_upstream_remote_url=$4
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"