diff options
| author | Carlos Maiolino <[email protected]> | 2025-02-03 17:19:00 +0100 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-02-03 17:19:00 +0100 |
| commit | 84fc31e1f824c9eccfd622eb7d89692a9357b3d7 (patch) | |
| tree | 43253cb2be150fd053e72fcc4c0023ed34e6682f | |
| parent | 68b192629fd63cf71d86e45548fe92279d598505 (diff) | |
Add pr-create
Initial WIP script for sending PRs
Signed-off-by: Carlos Maiolino <[email protected]>
| -rwxr-xr-x | maintainer/pr-create.sh | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/maintainer/pr-create.sh b/maintainer/pr-create.sh new file mode 100755 index 0000000..bffa72f --- /dev/null +++ b/maintainer/pr-create.sh @@ -0,0 +1,106 @@ +#!/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 <[email protected]>" +RECIPIENT="[email protected]" + +# Sending email global vars +usage() { + echo "usage: pr-create <branch> <tag>" +} + +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 |
