feat: specify which remote to push

This commit is contained in:
Klesh Wong 2023-08-17 11:37:32 +08:00
parent 6f489bc3bb
commit c7b0d0014d

View File

@ -2,8 +2,8 @@
set -e
# github pr helper
# push current branch to ORIGIN and create a PR on UPSTREAM
# UPSTREAM must be a https github url
# push current branch to ORIGIN(remote) and create a PR toward UPSTREAM(remote)
# UPSTREAM must be a https github url
if [ -n "$PROXY_HOST" ] && [ -n "$PROXY_PORT" ]; then
export HTTP_PROXY=http://$PROXY_HOST:$PROXY_PORT
echo HTTP_PROXY=$HTTP_PROXY
@ -12,7 +12,8 @@ fi
BRANCH=$(git branch --show-current)
UPSTREAM_BRANCH=$(HTTPS_PROXY=$HTTP_PROXY git remote show upstream | grep -oP 'HEAD branch: \K\w+')
ORIGIN_URL=$(git remote get-url origin)
ORIGIN_NAME=${1:-origin}
ORIGIN_URL=$(git remote get-url $ORIGIN_NAME)
case "$ORIGIN_URL" in
git@github.com:*)
ORIGIN_ORG=$(printf "$ORIGIN_URL" | sed -E 's#^.+:([^/]+).+$#\1#')
@ -23,7 +24,7 @@ UPSTREAM_URL=$(git remote get-url upstream)
UPSTREAM_URL=$(echo "$UPSTREAM_URL" | sed 's/.git$//')
echo ORIGIN_ORG: $ORIGIN_ORG
echo UPSTREAM_URL: $UPSTREAM_URL
git push -f -u origin $BRANCH
git push -f -u $ORIGIN_NAME $BRANCH
x-open "$UPSTREAM_URL/compare/$UPSTREAM_BRANCH...$ORIGIN_ORG:$BRANCH?expand=1"
sleep 2
command -v awesome-client && awesome-client '