dim: Add extract-tags command
PATCH 1/2 dim: Add extract-tags command
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
--- dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
dim +60 -0
@@ -333,6 +333,28 @@ if message_id is not None: EOF } +message_print_body () +{ + python2 <<EOF +import email + +def print_part(part): + mtype = part.get_content_maintype() + if mtype == 'text': + print(part.get_payload(decode=True)) + +def print_msg(file): + msg = email.message_from_file(file) + if msg.is_multipart(): + for part in msg.get_payload(): + print_part(part) + else: + print_part(msg) + +print_msg(open('$1', 'r')) +EOF +} + # append all arguments as tags at the end of the commit message of HEAD function dim_commit_add_tag {
@@ -973,6 +995,44 @@ function rangeish() fi } +dim_alias_xt=extract-tags +function dim_extract_tags +{ + local branch=$1 + shift + local range=$(rangeish "$1") + local file=`mktemp` + + assert_branch $branch + assert_repo_clean + + cat > $file + + echo "message_print_body \"$file\"" + local tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]') + test -n "$tags" || return 0 + local tags=$(printf -- "--- extracted tags ---\n%s" "$tags") + git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range +} + +dim_alias_xq=extract-queued +function dim_extract_queued +{ + dim_extract_tags drm-intel-next-queued "$@" +} + +dim_alias_xf=extract-fixes +function dim_extract_fixes +{ + dim_extract_tags drm-intel-fixes "$@" +} + +dim_alias_xnf=extract-next-fixes +function dim_extract_next_fixes +{ + dim_extract_tags drm-intel-next-fixes "$@" +} + dim_alias_check_patch=checkpatch dim_alias_cp=checkpatch function dim_checkpatch
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 dim: Add add-link command
From: Ville Syrjälä <[email protected]>
Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly.
--- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
dim +39 -0
@@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_ll=add-link +function dim_add_link +{ + local branch=$1 + shift + local file=`mktemp` + + assert_branch $branch + assert_repo_clean + + cat > $file + + local message_id=$(message_get_id $file) + + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echo "No message-id found in the patch file." + fi +} + +dim_alias_lq=add-link-queued +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +dim_alias_lf=add-link-fixes +function dim_add_link_fixes +{ + dim_add_link drm-intel-fixes "$@" +} + +dim_alias_lnf=add-link-next-fixes +function dim_add_link_next_fixes +{ + dim_add_link drm-intel-next-fixes "$@" +} + dim_alias_aq=apply-queued function dim_apply_queued {
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH dim 2/2] dim: Add add-link command
Quoted 15 lines · On Tue, 14 Mar 2017, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly.
Signed-off-by Ville Syrjälä <[email protected]>--- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)dim +0
-0
dim function dim_apply_branch · line 672
Quoted 9 lines
dim +6
-0@@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_ll=add-link +function dim_add_link +{ + local branch=$1 + shift + local file=`mktemp`
Same complaints about locals as in previous patch.
dim function dim_apply_branch · line 684
Quoted 12 lines
dim +12
-0+ + assert_branch $branch + assert_repo_clean + + cat > $file + + local message_id=$(message_get_id $file) + + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echo "No message-id found in the patch file."
Please use echoerr to print to stderr.
Quoted 11 lines
dim +11
-0+ fi +} + +dim_alias_lq=add-link-queued +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +dim_alias_lf=add-link-fixes +function dim_add_link_fixes
dim function dim_apply_branch · line 705
Quoted 10 lines
dim +10
-0+{ + dim_add_link drm-intel-fixes "$@" +} + +dim_alias_lnf=add-link-next-fixes +function dim_add_link_next_fixes +{ + dim_add_link drm-intel-next-fixes "$@" +} +
I'm thinking this one's so rarely used that the aliases are not needed. Short aliases will make dim bash completion less useful, as the completion automatically completes all dim commands and aliases.
Quoted 3 lines
dim +0
-0dim_alias_aq=apply-queued function dim_apply_queued {
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH dim 2/2] dim: Add add-link command
Quoted 28 lines · Jani Nikula
Quoted 15 lines · On Tue, 14 Mar 2017, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly.
Signed-off-by Ville Syrjälä <[email protected]>--- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)dim +0
-0dim function dim_apply_branch · line 672
Quoted 9 lines
dim +6
-0@@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_ll=add-link +function dim_add_link +{ + local branch=$1 + shift + local file=`mktemp`Same complaints about locals as in previous patch.
Quoted 7 lines
dim function dim_apply_branch · line 679
Quoted 7 lines
dim +7
-0+ + assert_branch $branch + assert_repo_clean + + cat > $file + + local message_id=$(message_get_id $file)
rm -f $file
Quoted 37 lines
dim function dim_apply_branch · line 684
Quoted 5 lines
dim +5
-0+ + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echo "No message-id found in the patch file."Please use echoerr to print to stderr.
Quoted 11 lines
dim +11
-0+ fi +} + +dim_alias_lq=add-link-queued +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +dim_alias_lf=add-link-fixes +function dim_add_link_fixesdim function dim_apply_branch · line 705
Quoted 10 lines
dim +10
-0+{ + dim_add_link drm-intel-fixes "$@" +} + +dim_alias_lnf=add-link-next-fixes +function dim_add_link_next_fixes +{ + dim_add_link drm-intel-next-fixes "$@" +} +I'm thinking this one's so rarely used that the aliases are not needed. Short aliases will make dim bash completion less useful, as the completion automatically completes all dim commands and aliases.
Quoted 3 lines
dim +0
-0dim_alias_aq=apply-queued function dim_apply_queued {
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH dim 2/2] dim: Add add-link command
Quoted 29 lines · Jani Nikula
Quoted 28 lines · Jani Nikula
Quoted 15 lines · On Tue, 14 Mar 2017, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly.
Signed-off-by Ville Syrjälä <[email protected]>--- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)dim +0
-0dim function dim_apply_branch · line 672
Quoted 9 lines
dim +6
-0@@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +dim_alias_ll=add-link +function dim_add_link +{ + local branch=$1 + shift + local file=`mktemp`Same complaints about locals as in previous patch.
Quoted 9 lines
Quoted 7 lines
dim function dim_apply_branch · line 679
Quoted 7 lines
dim +7
-0+ + assert_branch $branch + assert_repo_clean + + cat > $file + + local message_id=$(message_get_id $file)rm -f $file
Indeed. And looks like it's missing from extract-tags as well.
Quoted 26 lines
Quoted 26 lines
dim function dim_apply_branch · line 684
Quoted 6 lines
dim +5
-0+ + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echo "No message-id found in the patch file."Please use echoerr to print to stderr.
Quoted 17 lines
dim +17
-0+ fi +} + +dim_alias_lq=add-link-queued +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +dim_alias_lf=add-link-fixes +function dim_add_link_fixes +{ + dim_add_link drm-intel-fixes "$@" +} + +dim_alias_lnf=add-link-next-fixes +function dim_add_link_next_fixes
Quoted 8 lines
Quoted 8 lines
dim function dim_apply_branch · line 705
Quoted 4 lines
dim +4
-0+{ + dim_add_link drm-intel-next-fixes "$@" +} +I'm thinking this one's so rarely used that the aliases are not needed. Short aliases will make dim bash completion less useful, as the completion automatically completes all dim commands and aliases.
I've not used bash completion for this stuff so far, so the short commands have been handy. But I can always move it all into my .dimrc.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
dim +0
-0dim_alias_aq=apply-queued function dim_apply_queued {Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH dim 2/2] dim: Add add-link command
Quoted 2 lines · Ville Syrjälä
I've not used bash completion for this stuff so far, so the short commands have been handy. But I can always move it all into my .dimrc.
Oh, you should give the bash completions a try! It completes more than just the subcommands, e.g. 'dim co TAB' completes the branches.
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/2 dim: Add add-link command
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Add the "add-link" command so that you can add the Link: tag to patches that failed to apply directly.
v2: Drop the aliases
Remove the temp file
Clean up locals
Use echoerr for error prints
--- dim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
dim +39 -0
@@ -664,6 +664,45 @@ function dim_apply_branch eval $DRY $DIM_POST_APPLY_ACTION } +function dim_add_link +{ + local branch file message_id + + branch=$1 + shift + file=$(mktemp) + + assert_branch $branch + assert_repo_clean + + cat > $file + + message_id=$(message_get_id $file) + + rm -f $file + + if [ -n $message_id ]; then + dim_commit_add_tag "Link: http://patchwork.freedesktop.org/patch/msgid/$message_id" + else + echoerr "No message-id found in the patch file." + fi +} + +function dim_add_link_queued +{ + dim_add_link drm-intel-next-queued "$@" +} + +function dim_add_link_fixes +{ + dim_add_link drm-intel-fixes "$@" +} + +function dim_add_link_next_fixes +{ + dim_add_link drm-intel-next-fixes "$@" +} + dim_alias_aq=apply-queued function dim_apply_queued {
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 54 lines · On Tue, 14 Mar 2017, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
Signed-off-by Ville Syrjälä <[email protected]>--- dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)dim +22
-0@@ -333,6 +333,28 @@ if message_id is not None: EOF } +message_print_body () +{ + python2 <<EOF +import email + +def print_part(part): + mtype = part.get_content_maintype() + if mtype == 'text': + print(part.get_payload(decode=True)) + +def print_msg(file): + msg = email.message_from_file(file) + if msg.is_multipart(): + for part in msg.get_payload(): + print_part(part) + else: + print_part(msg) + +print_msg(open('$1', 'r')) +EOF +} + # append all arguments as tags at the end of the commit message of HEAD function dim_commit_add_tag {
dim function rangeish() · line 1004
Quoted 10 lines
dim +7
-0@@ -973,6 +995,44 @@ function rangeish() fi } +dim_alias_xt=extract-tags +function dim_extract_tags +{ + local branch=$1 + shift + local range=$(rangeish "$1") + local file=`mktemp`
So shell has an annoying feature that the 'set -e' has no effect on commands failing when used in an initialization within the local variable declaration. Simple assignments would be okay, but for clarity I've opted to put all local variable declarations in a single line, folled by a blank line and then assignments. See elsewhere in dim.
I also prefer $(...) over ....
dim function rangeish() · line 1011
Quoted 7 lines
dim +7
-0+ + assert_branch $branch + assert_repo_clean + + cat > $file + + echo "message_print_body \"$file\""
Leftover debug message?
dim function rangeish() · line 1012
Quoted 1 line
dim +1
-0+ local tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')
That's indeed quite liberal in accepting stuff. But perhaps it's okay for starters, and we can restrict it more if it gets to be annoying.
dim function rangeish() · line 1013
Quoted 1 line
dim +1
-0+ test -n "$tags" || return 0
Maybe it's just me trying to maintain a 1.5k line shell script, but I'd like to be more verbose with the if statements. I'd write this as
if [[ -n "$tags" ]]; then ...
dim function rangeish() · line 1014
Quoted 1 line
dim +1
-0+ local tags=$(printf -- "--- extracted tags ---\n%s" "$tags")
Lose the local here. Nitpick, AFAICT most git commands (like format-patch) wrap placeholders in *** rather than ---.
An interesting observation, if you put # in front of the line, you can actually have that as part of the commit message. But after you do 'git commit --amend' on it, the line gets dropped as a comment automatically. In short, that would save a couple of keystrokes perhaps, even if you'd have to move the other tags around.
dim function rangeish() · line 1015
Quoted 1 line
dim +1
-0+ git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
I wonder what I screwed up when I was trying to use that for dim_commit_add_tag and failed; the current implementation of it is hidous. :/
Quoted 9 lines
dim +9
-0+} + +dim_alias_xq=extract-queued +function dim_extract_queued +{ + dim_extract_tags drm-intel-next-queued "$@" +} + +dim_alias_xf=extract-fixes
dim function rangeish() · line 1034
Quoted 10 lines
dim +10
-0+function dim_extract_fixes +{ + dim_extract_tags drm-intel-fixes "$@" +} + +dim_alias_xnf=extract-next-fixes +function dim_extract_next_fixes +{ + dim_extract_tags drm-intel-next-fixes "$@" +}
These are all in line with what we have all around, but makes me wonder if we should consider just working on the current branch in the future.
Thanks for doing this, regardless of the nitpicks above. ;)
BR,
Jani.
Quoted 4 lines
dim +1
-0+ dim_alias_check_patch=checkpatch dim_alias_cp=checkpatch function dim_checkpatch
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 72 lines · Jani Nikula
Quoted 54 lines · On Tue, 14 Mar 2017, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
Signed-off-by Ville Syrjälä <[email protected]>--- dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)dim +22
-0@@ -333,6 +333,28 @@ if message_id is not None: EOF } +message_print_body () +{ + python2 <<EOF +import email + +def print_part(part): + mtype = part.get_content_maintype() + if mtype == 'text': + print(part.get_payload(decode=True)) + +def print_msg(file): + msg = email.message_from_file(file) + if msg.is_multipart(): + for part in msg.get_payload(): + print_part(part) + else: + print_part(msg) + +print_msg(open('$1', 'r')) +EOF +} + # append all arguments as tags at the end of the commit message of HEAD function dim_commit_add_tag {dim function rangeish() · line 1004
Quoted 10 lines
dim +7
-0@@ -973,6 +995,44 @@ function rangeish() fi } +dim_alias_xt=extract-tags +function dim_extract_tags +{ + local branch=$1 + shift + local range=$(rangeish "$1") + local file=`mktemp`So shell has an annoying feature that the 'set -e' has no effect on commands failing when used in an initialization within the local variable declaration. Simple assignments would be okay, but for clarity I've opted to put all local variable declarations in a single line, folled by a blank line and then assignments. See elsewhere in dim.
Quoted 1 line
I also prefer $(...) over
....
dim is a bit of a hodge podge of varying styles. Which is why my copy-paste coding technique gave me all kinds of things ;)
Quoted 10 lines
dim function rangeish() · line 1011
Quoted 8 lines
dim +7
-0+ + assert_branch $branch + assert_repo_clean + + cat > $file + + echo "message_print_body \"$file\""Leftover debug message?
Most likely. Dropped.
Quoted 5 lines
dim function rangeish() · line 1012
Quoted 2 lines
dim +1
-0+ local tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')That's indeed quite liberal in accepting stuff. But perhaps it's okay for starters, and we can restrict it more if it gets to be annoying.
I've had surprisingly few false positives with this myself. But yeah, it can always be refined. Or if needed we could even make it user configurable.
Quoted 8 lines
dim function rangeish() · line 1013
Quoted 2 lines
dim +1
-0+ test -n "$tags" || return 0Maybe it's just me trying to maintain a 1.5k line shell script, but I'd like to be more verbose with the if statements. I'd write this as
if [[ -n "$tags" ]]; then ...
Done
Quoted 5 lines
dim function rangeish() · line 1014
Quoted 2 lines
dim +1
-0+ local tags=$(printf -- "--- extracted tags ---\n%s" "$tags")Lose the local here. Nitpick, AFAICT most git commands (like format-patch) wrap placeholders in *** rather than ---.
Dunno. I can live with either, so changed to ***
Quoted 6 lines
An interesting observation, if you put # in front of the line, you can actually have that as part of the commit message. But after you do 'git commit --amend' on it, the line gets dropped as a comment automatically. In short, that would save a couple of keystrokes perhaps, even if you'd have to move the other tags around.
That's a nice idea. I'll give it a go.
Quoted 20 lines
dim function rangeish() · line 1015
Quoted 2 lines
dim +1
-0+ git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $rangeI wonder what I screwed up when I was trying to use that for
dim_commit_add_tagand failed; the current implementation of it is hidous. :/Quoted 13 lines
dim +13
-0+} + +dim_alias_xq=extract-queued +function dim_extract_queued +{ + dim_extract_tags drm-intel-next-queued "$@" +} + +dim_alias_xf=extract-fixes +function dim_extract_fixes +{ + dim_extract_tags drm-intel-fixes "$@" +}
Quoted 8 lines
dim function rangeish() · line 1034
Quoted 6 lines
dim +6
-0+ +dim_alias_xnf=extract-next-fixes +function dim_extract_next_fixes +{ + dim_extract_tags drm-intel-next-fixes "$@" +}These are all in line with what we have all around, but makes me wonder
I can drop the aliases here as well if people prefer. My .dimrc already has a boatload of these for all the other branches so having to move a few more there isn't a big deal.
Quoted 1 line
if we should consider just working on the current branch in the future.
Not sure there is any "current branch" as such when you have worktrees for everything.
Quoted 13 lines
Thanks for doing this, regardless of the nitpicks above. ;)
BR,
Jani.Quoted 4 lines
dim +1
-0+ dim_alias_check_patch=checkpatch dim_alias_cp=checkpatch function dim_checkpatchSignature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 73 lines · Ville Syrjälä
Quoted 72 lines · Jani Nikula
Quoted 54 lines · On Tue, 14 Mar 2017, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
Signed-off-by Ville Syrjälä <[email protected]>--- dim | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)dim +22
-0@@ -333,6 +333,28 @@ if message_id is not None: EOF } +message_print_body () +{ + python2 <<EOF +import email + +def print_part(part): + mtype = part.get_content_maintype() + if mtype == 'text': + print(part.get_payload(decode=True)) + +def print_msg(file): + msg = email.message_from_file(file) + if msg.is_multipart(): + for part in msg.get_payload(): + print_part(part) + else: + print_part(msg) + +print_msg(open('$1', 'r')) +EOF +} + # append all arguments as tags at the end of the commit message of HEAD function dim_commit_add_tag {dim function rangeish() · line 1004
Quoted 10 lines
dim +7
-0@@ -973,6 +995,44 @@ function rangeish() fi } +dim_alias_xt=extract-tags +function dim_extract_tags +{ + local branch=$1 + shift + local range=$(rangeish "$1") + local file=`mktemp`So shell has an annoying feature that the 'set -e' has no effect on commands failing when used in an initialization within the local variable declaration. Simple assignments would be okay, but for clarity I've opted to put all local variable declarations in a single line, folled by a blank line and then assignments. See elsewhere in dim.
Quoted 4 lines
Quoted 1 line
I also prefer $(...) over
....dim is a bit of a hodge podge of varying styles. Which is why my copy-paste coding technique gave me all kinds of things ;)
I know... I've been trying to gradually clean it up, and I think I have a branch fixing a bunch of shellcheck issues too. I'm sure some might feel that enforcing a style or shellcheck cleanliness in a shell script is overkill, but I'm thinking overgrown shell scripts like this will become completely unmaintainable otherwise.
Quoted 5 lines
Quoted 1 line
These are all in line with what we have all around, but makes me wonder
I can drop the aliases here as well if people prefer. My .dimrc already has a boatload of these for all the other branches so having to move a few more there isn't a big deal.
Yeah, let's drop the aliases, at least for now. Having an alias mechanism (that also bash autocompletes for user defined aliases) should be good enough. Again, can be added later if there's demand.
Quoted 5 lines
Quoted 2 lines
if we should consider just working on the current branch in the future.
Not sure there is any "current branch" as such when you have worktrees for everything.
Right.
BR,
Jani.
Quoted 14 lines
Quoted 14 lines
Thanks for doing this, regardless of the nitpicks above. ;)
BR,
Jani.Quoted 4 lines
dim +1
-0+ dim_alias_check_patch=checkpatch dim_alias_cp=checkpatch function dim_checkpatchSignature · 1 line
Jani Nikula, Intel Open Source Technology Center
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/2 dim: Add extract-tags command
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
v2: Drop the aliases
Remove the temp file
Clean up locals
Other codingstyle cleanups
Use '# *** ... ***' for the separator
--- dim | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
dim +64 -0
@@ -333,6 +333,28 @@ if message_id is not None: EOF } +message_print_body () +{ + python2 <<EOF +import email + +def print_part(part): + mtype = part.get_content_maintype() + if mtype == 'text': + print(part.get_payload(decode=True)) + +def print_msg(file): + msg = email.message_from_file(file) + if msg.is_multipart(): + for part in msg.get_payload(): + print_part(part) + else: + print_part(msg) + +print_msg(open('$1', 'r')) +EOF +} + # append all arguments as tags at the end of the commit message of HEAD function dim_commit_add_tag {
@@ -973,6 +995,48 @@ function rangeish() fi } +function dim_extract_tags +{ + local branch range file tags + + branch=$1 + shift + range=$(rangeish "$1") + file=$(mktemp) + + assert_branch $branch + assert_repo_clean + + cat > $file + + tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]') + + rm -f $file + + if [[ -z "$tags" ]]; then + return 0 + fi + + tags=$(printf -- "# *** extracted tags ***\n%s" "$tags") + + git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range +} + +function dim_extract_queued +{ + dim_extract_tags drm-intel-next-queued "$@" +} + +function dim_extract_fixes +{ + dim_extract_tags drm-intel-fixes "$@" +} + +function dim_extract_next_fixes +{ + dim_extract_tags drm-intel-next-fixes "$@" +} + dim_alias_check_patch=checkpatch dim_alias_cp=checkpatch function dim_checkpatch
Signature · 6 lines
2.10.2 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · On Wed, Mar 15, 2017 at 05:09:04PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
Quoted 8 lines
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
An example of typical use would be nice.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 16 lines · Chris Wilson
Quoted 6 lines · On Wed, Mar 15, 2017 at 05:09:04PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
Quoted 8 lines
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
Quoted 1 line
An example of typical use would be nice.
I believe you can pipe an email to 'dim extract-tags' or one of its variants, and have the tags in the email applied to the commits in the branch in question.
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 17 lines · Jani Nikula
Quoted 16 lines · Chris Wilson
Quoted 14 lines · On Wed, Mar 15, 2017 at 05:09:04PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
Quoted 5 lines
Quoted 1 line
An example of typical use would be nice.
I believe you can pipe an email to 'dim extract-tags' or one of its variants, and have the tags in the email applied to the commits in the branch in question.
Yes. My typical work flow with mutt is something like 'open patch mail ;
| dim apply... ; open reply mail with tag(s) ; | dim extract...'.
Or if someone has r-b'd an entire series I apply everything first, and then do 'dim extract... <remote>/drm-intel-next-queued..HEAD' to slap the tag(s) onto all the commits.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 24 lines · Ville Syrjälä
Quoted 17 lines · Jani Nikula
Quoted 16 lines · Chris Wilson
Quoted 14 lines · On Wed, Mar 15, 2017 at 05:09:04PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Add a command for extracting various tags (eg. Reviwed-by:) from emails. You can give the comamnd a rangeish to add the tags from the same email to multiple already applied patches.
The regexp used to pick up tags is purposefully quite broad. People tend to typo these things, or add extra whitespace etc. However the broad regexp does mean this occasionally picks up stuff that isn't a tag. So manually amending the commit is probably a wise idea, and so I simply decided to also leave a '--- extracted tags ---' separator in the commit message just before the extracted tags, which can be cleaned up manually when verifying that the tags look correct.
Quoted 5 lines
Quoted 1 line
An example of typical use would be nice.
I believe you can pipe an email to 'dim extract-tags' or one of its variants, and have the tags in the email applied to the commits in the branch in question.
Quoted 5 lines
Yes. My typical work flow with mutt is something like 'open patch mail ;
| dim apply... ; open reply mail with tag(s) ; | dim extract...'.
Or if someone has r-b'd an entire series I apply everything first, and then do 'dim extract... <remote>/drm-intel-next-queued..HEAD' to slap the tag(s) onto all the commits.
Pushed both patches (though I guess you could have yourself too). Please update the dim.rst man page too.
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx