aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2020-10-21 00:52:18 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2020-10-21 00:53:23 +0200
commitc05013d15f20ce44e98ddf8b2cba0762c731c6c7 (patch)
tree8ba1e56ec1e819239a00f8dd7412569c1eb8c64e
parent88c42335247f713c13a0fceb97f6f49fc03c7013 (diff)
downloadpw-c05013d15f20ce44e98ddf8b2cba0762c731c6c7.tar.gz
pw: teach pw-apply to grab the cover letter and the series
Workflow steps: - Click on any patch in patchwork.kernel.org (doesn't need to be the link to series) - Copy top url that returns html (not mbox one) - pw-apply -c url It will fetch the html and find links in there to cover letter and full series. If there is a cover it will automatically create a merge commit with that cover. If there is no cover it will apply the whole series. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rwxr-xr-xpw-apply27
1 files changed, 23 insertions, 4 deletions
diff --git a/pw-apply b/pw-apply
index df07552..30345ab 100755
--- a/pw-apply
+++ b/pw-apply
@@ -38,11 +38,24 @@ accept_series()
exit
}
+cover_from_url()
+{
+ curl -s $1 | gunzip -f -c > tmp.i
+ series_num=`grep "href=\"/series" tmp.i|cut -d/ -f3|head -1`
+ cover_num=`grep "href=\"/cover" tmp.i|cut -d/ -f3|head -1`
+ if [ ! -z "$cover_num" ]; then
+ curl -s https://patchwork.kernel.org/cover/$cover_num/mbox/ | gunzip -f -c > cover.i
+ merge="1"
+ fi
+ curl -s https://patchwork.kernel.org/series/$series_num/mbox/ | gunzip -f -c > mbox.i
+}
+
branch="mbox"
series=""
accept=""
merge=""
mbox=""
+cover=""
head_old=$(git rev-parse --verify HEAD)
while true; do
case "$1" in
@@ -50,36 +63,42 @@ while true; do
-a | --accept ) accept="1"; shift ;;
-m | --merge ) merge="1"; branch="$2"; shift 2 ;;
-b | --mbox ) mbox="$2"; shift 2 ;;
+ -c | --cover) branch="tmp"; cover="$2"; shift 2 ;;
-h | --help ) usage; break ;;
-- ) shift; break ;;
* ) break ;;
esac
done
[ ! -z "$mbox" ] && [ ! -z "$series" ] && usage
-[ -z "$mbox" ] && [ -z "$series" ] && usage
+[ -z "$mbox" ] && [ -z "$series" ] && [ -z "$cover" ] && usage
[ ! -z "$accept" ] && [ ! -z "$mbox" ] && usage
[ ! -z "$series" ] && mbox_from_series $series
[ ! -z "$mbox" ] && mbox_from_url $mbox
[ ! -z "$accept" ] && accept_series $series
+[ ! -z "$cover" ] && cover_from_url $cover
git checkout -b $branch
mb2q --mboxout mbox.o "$@" mbox.i
git am -3 mbox.o
git checkout master
if [ ! -z "$merge" ]; then
git merge --stat --log --no-edit --no-ff $branch
+ author=`grep 'X-Patchwork-Submitter:' cover.i|cut -f2,3 -d' '`
+ branch_name=`grep 'Subject:' cover.i|cut -d']' -f2|cut -d' ' -f2-10`
+ text=`grep -A300 'X-Mailing-List:' cover.i |tail --lines=+3|grep -B300 "$author"|head --lines=-2`
git commit --amend --signoff -F- <<EOF
-Merge branch '$branch'
+Merge branch '$branch_name'
-XYZ says:
+$author says:
====================
+$text
====================
EOF
else
git merge --stat --ff $branch
fi
git branch -d $branch
-rm -f mbox.i mbox.o
+rm -f mbox.i mbox.o tmp.i cover.i
head_new=$(git rev-parse --verify HEAD)
pw-check -s $head_old -e $head_new
if [ ! -z "$merge" ]; then