Skip to content

Commit

Permalink
Update example hooks to be remote aware
Browse files Browse the repository at this point in the history
Update example hooks to be remote aware so that they work with people
that are using multiple patch stacks related to multiple remotes.

skip_ticket_id_check

<!-- ps-id: dbda2455-2d35-4713-8670-3c68a74d02b9 -->
  • Loading branch information
drewdeponte committed Jun 21, 2023
1 parent 9c1535b commit f21d306
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
15 changes: 15 additions & 0 deletions example_hooks/isolate_post_checkout-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# isolate_post_checkout hook using GitHub CLI (https://cli.github.com)
#
# This hook handles verifying a patch is isolated after checking out the
# temporary ps/tmp/isolate branch.
#
# gps exposes the remote name and remote url respective as arg 1 and 2
#
# Generally you want this script to verify that your code builds,
# your tests pass, and any other constraints you want to add here
# to make sure your code is good prior to integration. People often add linting

remote_name=$1 # string of the remote name (e.g. origin)
remote_url=$2 # string of the remote url
4 changes: 3 additions & 1 deletion example_hooks/request_review_post_sync-github-cli-example
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
re_requesting_review=$1 # string of "true" or "false"
branch_to_integrate=$2 # string of the branch name to integrate (e.g. ps/rr/your-patches-branch-name)
branch_to_integrate_into=$3 # string of the branch name to integrate into (e.g. main)
remote_name=$4 # string of the remote name (e.g. origin)
remote_url=$5 # string of the remote url

if [ "$re_requesting_review" != "true" ]; then
gh pr create --fill --base "$branch_to_integrate_into" --head "$branch_to_integrate"
gh pr create --fill --base "$branch_to_integrate_into" --head "$branch_to_integrate" -R "$remote_url"
fi

# Note: In the case where $re_requesting_review is true we don't want to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
re_requesting_review=$1 # string of "true" or "false"
branch_to_integrate=$2 # string of the branch name to integrate (e.g. ps/rr/your-patches-branch-name)
branch_to_integrate_into=$3 # string of the branch name to integrate into (e.g. main)
remote_name=$4 # string of the remote name (e.g. origin)
remote_url=$5 # string of the remote url

# If true then open the PR to view it online else create it
if [ "$re_requesting_review" == "true" ]; then
gh pr view "$branch_to_integrate" --web
gh pr view "$branch_to_integrate" --web -R "$remote_url"
else
# Consider using the reviewer flag on a project level hook if you have teams like @dev ie: --reviewer @dev
gh pr create --assignee @me --fill --web --base "$branch_to_integrate_into" --head "$branch_to_integrate"
gh pr create --assignee @me --fill --web --base "$branch_to_integrate_into" --head "$branch_to_integrate" -R "$remote_url"
fi

0 comments on commit f21d306

Please sign in to comment.