#!/bin/bash # pr-create: # # Create a Pull Request and send it to Linus Torvalds # # This script does: # # - Create a signed tag # - push the branch and the tag to xfs-linux repository # - Generate a list of patches in short-form # - Craft a PR and email to Linus. # #REMOTE="cem-xfs" REMOTE="xfs-linux" BRANCH="$1" TAG="$2" TAG_MESSAGE="Signed-off-by: Carlos Maiolino " RECIPIENT="cem@kernel.org" # Sending email global vars usage() { echo "usage: pr-create " } die() { echo "${1}... Exiting" exit 1 } git_verify_branch() { local CUR_BRANCH=`git branch --show-current` if [ "${CUR_BRANCH}" != "${BRANCH}" ]; then echo "Different branch is checked out..." echo "... Attempting to checkout branch ${BRANCH}" git checkout -q ${BRANCH} 2> /dev/null if [ $? -ne 0 ]; then return 1 else # Reset status to the old branch git checkout -q ${CUR_BRANCH} 2> /dev/null fi fi } git_create_tag() { git tag -s ${TAG} -m "${TAG_MESSAGE}" } push_branch() { git push ${REMOTE} ${BRANCH}:${BRANCH} } push_tag() { git push ${REMOTE} ${TAG} } git_craft_pr() { local MSG=`git request-pull ${BRANCH} ${REMOTE} ${TAG}` echo -e "$MSG" } craft_message() { local MSG=$(git_craft_pr) cat << ENDL Hello Linus, Could you please pull patches included in the tag below? An attempt merge against your current TOT has been successful. Thanks, Carlos ${MSG} ENDL } generate_email() { local MUTT_CONFIG="$HOME/.mutt/muttrc-Kernel" neomutt -F ${MUTT_CONFIG} -s "$1" -i "$2" ${RECIPIENT} } if [ -z "${BRANCH}" ] || [ -z "${TAG}" ]; then usage fi git_verify_branch if [ $? -ne 0 ]; then die "Couldn't verify branch" fi MAIL_MSG=$(mktemp) craft_message > $MAIL_MSG SUBJ="[GIT PULL] XFS fixes for v6.14" generate_email "$SUBJ" $MAIL_MSG