Skip to content

Commit

Permalink
Add a convenient script to create internal PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
npaun committed Aug 27, 2024
1 parent 290b54c commit eb452d2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ test-asan *args="//...":

format:
python3 tools/cross/format.py

internal-pr:
./tools/unix/create-internal-pr.sh
38 changes: 38 additions & 0 deletions tools/unix/create-internal-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
# This tool will open a PR to update workerd in Cloudflare's internal repository
# to match the current branch.

set -euo pipefail

BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
SYNC_BRANCH_NAME=sync/$BRANCH_NAME

cd ../edgeworker
git fetch origin master

if git rev-parse --verify $SYNC_BRANCH_NAME; then
BRANCH_EXISTS=1
else
BRANCH_EXISTS=0
fi


if [ $BRANCH_EXISTS -eq 1 ]; then
git checkout $SYNC_BRANCH_NAME
else
git checkout master
git checkout -b $SYNC_BRANCH_NAME
fi

git -C deps/workerd fetch origin $BRANCH_NAME
git -C deps/workerd checkout origin/$BRANCH_NAME
git add deps/workerd

if [ $BRANCH_EXISTS -eq 1 ]; then
git commit --amend
git push --force origin HEAD
else
git commit -m "Sync with $BRANCH_NAME"
git push origin HEAD
open "https://bitbucket.cfdata.org/projects/EW/repos/edgeworker/pull-requests?create&sourceBranch=refs/heads/$SYNC_BRANCH_NAME"
fi

0 comments on commit eb452d2

Please sign in to comment.