Skip to content

Instantly share code, notes, and snippets.

@ermshiperete
Created May 12, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ermshiperete/e8ffae9d0947cf3cab831f6a496f0fc9 to your computer and use it in GitHub Desktop.
Save ermshiperete/e8ffae9d0947cf3cab831f6a496f0fc9 to your computer and use it in GitHub Desktop.
git-review
#!/bin/bash -e
# Submit a change for review
# Allow single-arg options to be passed to push -- principally -n
OPTIONS=()
while [[ "$1" == -* ]]
do
OPTIONS+=("$1")
shift
done
COMMIT=${3-HEAD}
SOURCE=${2-$(git symbolic-ref -q "$COMMIT" 2>/dev/null || git name-rev --name-only "$COMMIT" 2>/dev/null)}
TARGET=${1-develop}
SOURCE=${SOURCE#refs/heads/}
if [ "$SOURCE" = "$TARGET" ]; then
SOURCE=
fi
git push --signed "${OPTIONS[@]}" origin "$COMMIT:refs/for/$TARGET${SOURCE:+%topic=}$SOURCE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment