summaryrefslogtreecommitdiff
path: root/maintainer_old/pr-create.sh
blob: 948c441423aa1af01d76a2d9033b5b4af3b4cc68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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="xfs-linux"
BRANCH="$1"
TGT_BRANCH="linus/master"
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 ${TGT_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: New code for for v6.18"
generate_email "$SUBJ" $MAIL_MSG