Skip to content
File

Blob: tools/unix/create-internal-pr.sh

bash44 lines
1#!/usr/bin/env bash
2# This tool will open a PR to update workerd in Cloudflare's internal repository
3# to match the current branch.
4 
5set -euo pipefail
6 
7if [ -z "${EDGEWORKER_HOME+x}" ]; then
8 EDGEWORKER_HOME="$(git rev-parse --show-toplevel)/../edgeworker"
9fi
10 
11BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
12SYNC_BRANCH_NAME=sync/$BRANCH_NAME
13 
14cd $EDGEWORKER_HOME
15git submodule update --init --recursive
16git fetch origin master
17 
18if git rev-parse --verify $SYNC_BRANCH_NAME; then
19 BRANCH_EXISTS=1
20else
21 BRANCH_EXISTS=0
22fi
23 
24 
25if [ $BRANCH_EXISTS -eq 1 ]; then
26 git checkout $SYNC_BRANCH_NAME
27else
28 git checkout -b $SYNC_BRANCH_NAME origin/master
29fi
30 
31git -C deps/workerd fetch origin $BRANCH_NAME
32git -C deps/workerd checkout origin/$BRANCH_NAME
33git add deps/workerd
34 
35if [ $BRANCH_EXISTS -eq 1 ]; then
36 git commit --no-verify --amend
37 git push --no-verify --force origin HEAD
38else
39 git commit --no-verify -m "Sync with $BRANCH_NAME"
40 GIT_OUT="$(git push --no-verify origin HEAD 2>&1)"
41 echo "$GIT_OUT"
42 open $(echo "$GIT_OUT" | sed -n '/remote: *http/ s/remote: *\(.*\)/\1/p')
43fi