diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-04-21 09:11:11 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-04-24 10:25:00 +0200 |
commit | 7cec241aad7c3660d992b3dd540e13c4d142db50 (patch) | |
tree | e7ff2706f9c87ae0b6479ec869d6a99ed13d8a27 | |
parent | 2ae7bb1b1c03333794b0555fa281193712463615 (diff) | |
download | pw-7cec241aad7c3660d992b3dd540e13c4d142db50.tar.gz |
pw-apply: Unify the merge paths
Auto-merge only works with -s today, while BPF folks seem
to favor -c. Unify the two paths. Since both -c and -s
auto-detect merges make merges the default and let user
prevent merges instead. Or force a manual merge.
Both of those options will likely never be used anyway :)
Note that use of auto-merge changes the format of merge
commits slightly. A Link is added at the end, but more
notably we use a real branch name, e.g.:
Merge branch 'net-give-napi_threaded_poll-some-love'
instead of the constructed message:
Merge branch 'net: give napi_threaded_poll() some love'
the subject now lands as the first line of the body:
Merge branch 'net-give-napi_threaded_poll-some-love'
Eric Dumazet says:
====================
net: give napi_threaded_poll() some love
There is interest to revert commit 4cd13c21b207...
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rwxr-xr-x | pw-apply | 52 |
1 files changed, 16 insertions, 36 deletions
@@ -8,7 +8,7 @@ source $(dirname $0)/lib.sh usage() { cat <<-EOF - usage: pw-apply [-h] [-s SERIES] [-b MBOX] [-m BRANCHNAME] [-M] + usage: pw-apply [-h] [-s SERIES] [-b MBOX] [-P] [-M] [-a] [-3] [-N] [-e] [-T] -- [-C] [-a ACKEDBY] [-r REVIEWEDBY] [-t TESTEDBY] EOF @@ -83,21 +83,20 @@ accept_series() cover_from_url() { curl -s $1 | gunzip -f -c > tmp.i - series_num=`grep "href=\"/series" tmp.i|cut -d/ -f3|head -1` + series=`grep "href=\"/series" tmp.i|cut -d/ -f3|head -1` cover_url=`grep "href=\"/project/netdevbpf/cover" tmp.i|cut -d\" -f2` - if [ ! -z "$cover_url" ]; then - curl -s https://patchwork.kernel.org${cover_url}mbox/ | gunzip -f -c > cover.i - merge="1" + if [ -z "$cover_url" ]; then + merge= fi - curl -s https://patchwork.kernel.org/series/$series_num/mbox/ | gunzip -f -c > mbox.i } +auto_branch="1" edits="" am_flags="" -branch="mbox" series="" accept="" -merge="" +merge="1" +no_merge="" mbox="" cover="" cover_tags="y" @@ -110,16 +109,19 @@ while true; do -a | --accept ) accept="1"; shift ;; -e | --do-edits ) edits="1"; shift ;; -N | --no-mb2q ) mb2q_normalize=""; am_flags="$am_flags -s"; shift ;; - -m | --merge ) merge="1"; branch="$2"; shift 2 ;; - -M | --auto-merge) merge="1"; auto_branch="1"; shift ;; + -P | --no-merge ) no_merge="1"; shift ;; + -M | --manual-merge) auto_branch=""; shift ;; -b | --mbox ) mbox="$2"; shift 2 ;; - -c | --cover) branch="tmp"; cover="$2"; shift 2 ;; + -c | --cover) cover="$2"; shift 2 ;; -T | --no-cover-tags) cover_tags=""; shift ;; -h | --help ) usage; break ;; -- ) shift; break ;; * ) break ;; esac done +# Load the info from cover first, it may will populate $series and $merge +[ ! -z "$cover" ] && cover_from_url $cover + [ ! -z "$auto_branch" ] && [ -z "$series" ] && usage [ ! -z "$mbox" ] && [ ! -z "$series" ] && usage [ -z "$mbox" ] && [ -z "$series" ] && [ -z "$cover" ] && usage @@ -127,9 +129,10 @@ done [ ! -z "$series" ] && mbox_from_series $series [ ! -z "$mbox" ] && mbox_from_url $mbox [ ! -z "$accept" ] && accept_series $series -[ ! -z "$cover" ] && cover_from_url $cover +[ ! -z "$no_merge" ] && merge= target=$(git branch --show-current) +branch="mbox" body= author=XYZ @@ -178,29 +181,7 @@ fi git checkout "$target" if [ ! -z "$merge" ]; then git merge --stat --log --no-edit --no-ff $branch - if [ ! -z "$cover" ]; then - author=$(grep 'X-Patchwork-Submitter:' cover.i | cut -d' ' -f2- | cut -d'<' -f1 | awk '{$1=$1;print}') - if [[ "$author" =~ ^=\?utf-8\?b\?(.*)\?=$ ]]; then - # strip away "=?utf-8?b?" prefix and "?=" suffix and base64-decode - author=$(echo "${BASH_REMATCH[1]}" | base64 -d) - elif [[ "$author" =~ ^=\?utf-8\?q\?(.*)\?=$ ]]; then - # strip away "=?utf-8?q?" prefix and "?=" suffix and quoted-printable-decode - author=$(echo "${BASH_REMATCH[1]}" | tr '_' ' ' | perl -MMIME::QuotedPrint -0777 -nle 'print decode_qp($_)') - fi - # Extract cover letter subject, potentially split into two lines - branch_name=$(awk '/^\w+: / { subj=0 } /^Subject: / { subj = 1 } subj { print $0 }' cover.i | tr -d '\n' | cut -d']' -f2 | cut -c 2-) - text=`grep -A300 'X-Mailing-List:' cover.i |tail --lines=+3|grep -B300 -E "^.*\([0-9]+\):$"|head --lines=-2` - git commit --amend --signoff -F- <<EOF -Merge branch '$branch_name' - -$author says: - -==================== -$text -==================== -EOF - else - git commit --amend --signoff -F- <<EOF + git commit --amend --signoff -F- <<EOF Merge branch '$branch' $author says: @@ -213,7 +194,6 @@ $body Link: https://lore.kernel.org/r/$cover_msgid EOF - fi else git merge --stat --ff $branch fi |