libreoffice-online/g
Miklos Vajna 2ca8cf9f7e Add a './g review' script to trigger CI for a commit in an easy way
Similar to gerrit's 'git review' which creates/updates a change without
clicking anywhere in a browser.

Also add a './g pull' to help those who are used to that.

Change-Id: I240ff55c7480d0a2cd6de3f2ea3cd84ca0556af4
2020-10-09 11:58:43 +02:00

38 lines
1.1 KiB
Bash
Executable file

#!/bin/bash -e
#
# './g pull -r' just forwards to 'git pull -r'.
#
# './g review' to submit a pull request, assuming:
# 1) You have 'gh' installed.
# 2) You are a committer, so you have the permission to push to a private/nick/name branch.
# 3) You delete this branch after the PR is merged.
#
if [ "$1" == "review" ]; then
if [ -z "$(type -p gh)" ]; then
echo "'gh' not found, install it from <https://github.com/cli/cli/blob/trunk/docs/install_linux.md>."
exit 1
fi
BRANCH=$(git symbolic-ref HEAD|sed 's|refs/heads/||')
REMOTE=$(git config branch.$BRANCH.remote)
if git rev-parse --quiet --verify $REMOTE/private/$USER/$BRANCH >/dev/null; then
# PR is open, just update it.
git push -f $REMOTE HEAD:private/$USER/$BRANCH
else
# Open a new PR.
git push $REMOTE HEAD:private/$USER/$BRANCH
git branch private/$USER/$BRANCH
gh pr create --base $BRANCH --head private/$USER/$BRANCH --fill
git branch -D private/$USER/$BRANCH
fi
exit 0
fi
if [ "$1" == "pull" ]; then
shift
git pull "$@"
exit 0
fi
# vim:set shiftwidth=4 softtabstop=4 expandtab: