Skip to content

Instantly share code, notes, and snippets.

@IanWhalen
Created January 14, 2020 14:05
Show Gist options
  • Save IanWhalen/038e705903074fb5545bb65a604e2f0b to your computer and use it in GitHub Desktop.
Save IanWhalen/038e705903074fb5545bb65a604e2f0b to your computer and use it in GitHub Desktop.
#!/bin/bash
# Helpful wrapper that uploads takes a single optional commit (defaulting to HEAD) and uploads
# the patch to cr with the subject and description based on the git commit message. This is
# useful if your workflow involves keeping a single commit that you intend to push per review,
# and modifying the commit based on feedback. This script is traditionally called {{cruc}}.
# Any additional arguments are passed directly to the upload script so you can still use {{-i issue_number}}.
UPLOAD_SCRIPT=fill
JIRA_USER=me
EMAIL=in@10gen.com
# This makes it work when sshed into a desktop that is running a browser logged in to google.
# Delete if that isn't part of your workflow.
export DISPLAY=:0
cr() {
python2 "$UPLOAD_SCRIPT" -y --git_similarity=100 "$@"
#python2 "$UPLOAD_SCRIPT" -y "$@"
}
cru() {
if [ -d "src/mongo" ]; then
cr -e $EMAIL --jira_user $JIRA_USER "$@" --check-clang-format --check-eslint
else
cr -e $EMAIL --jira_user $JIRA_USER "$@"
fi
}
if [[ -n "$1" && ${1:0:1} != '-' ]]; then
REV="$1"
shift
else
REV=""
fi
if [ -z "$REV" ]; then
REV="HEAD"
fi
REV_SELECTOR="${REV}~..${REV}"
SUBJ=$(git log "$REV_SELECTOR" --pretty=format:"%s")
BODY=$(git log "$REV_SELECTOR" --pretty=format:"%b")
cru --rev "${REV}~:$REV" \
-m "$SUBJ" \
--description "$BODY" \
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment