All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH dim 1/2] dim: Add support for multiple messages in extract-tags
@ 2017-03-23 21:07 Sean Paul
  2017-03-23 21:07 ` [PATCH dim 2/2] dim: Curate and insert tags into patch(es) Sean Paul
  0 siblings, 1 reply; 9+ messages in thread
From: Sean Paul @ 2017-03-23 21:07 UTC (permalink / raw)
  To: intel-gfx, ville.syrjala

Make extract-tags process tags from all messages in the supplied
mbox. This allows the user to tag multiple replies and extract
all tags at once.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 dim | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/dim b/dim
index 989674a..43ea794 100755
--- a/dim
+++ b/dim
@@ -342,25 +342,27 @@ if message_id is not None:
 EOF
 }
 
-message_print_body ()
+mbox_cat_messages ()
 {
 	python2 <<EOF
 import email
+import mailbox
 
 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)
+def print_msg(msg):
     if msg.is_multipart():
         for part in msg.get_payload():
             print_part(part)
     else:
         print_part(msg)
 
-print_msg(open('$1', 'r'))
+mbox = mailbox.mbox('$1', create=False)
+for m in mbox.values():
+    print_msg(m)
 EOF
 }
 
@@ -1157,7 +1159,7 @@ function dim_extract_tags
 
 	cat > $file
 
-	tags=$(message_print_body "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')
+	tags=$(mbox_cat_messages "$file" | grep -ai '^[^>]*[A-Za-z-]\+: [^ ]')
 
 	rm -f $file
 
-- 
2.12.1.500.gab5fba24ee-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH dim 2/2] dim: Curate and insert tags into patch(es)
  2017-03-23 21:07 [PATCH dim 1/2] dim: Add support for multiple messages in extract-tags Sean Paul
@ 2017-03-23 21:07 ` Sean Paul
  2017-03-24  7:54   ` Jani Nikula
  2017-03-24  9:07   ` [PATCH dim " Ville Syrjälä
  0 siblings, 2 replies; 9+ messages in thread
From: Sean Paul @ 2017-03-23 21:07 UTC (permalink / raw)
  To: intel-gfx, ville.syrjala

Launch $EDITOR when extracting tags to curate the tags immediately. Once the
tags are proper, automatically add them before the first Signed-off-by line
to all patches in the range.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 dim | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/dim b/dim
index 43ea794..6a5580a 100755
--- a/dim
+++ b/dim
@@ -1145,6 +1145,12 @@ function rangeish()
 	fi
 }
 
+function insert_extracted_tags
+{
+	new_tabs=`cat $1 | awk '{ORS="\\\\n"} {print $0}' | head -c-3`
+	awk "/Signed-off-by/{p++} p==1{print \"$new_tabs\"; p++} p!=1{print}"
+}
+
 function dim_extract_tags
 {
 	local branch range file tags
@@ -1167,9 +1173,10 @@ function dim_extract_tags
 		return 0
 	fi
 
-	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
-
-	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
+	echo "$tags" > $file
+	$EDITOR $file
+	export -f insert_extracted_tags
+	git filter-branch -f --msg-filter "insert_extracted_tags $file" $range
 }
 
 function dim_extract_queued
-- 
2.12.1.500.gab5fba24ee-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH dim 2/2] dim: Curate and insert tags into patch(es)
  2017-03-23 21:07 ` [PATCH dim 2/2] dim: Curate and insert tags into patch(es) Sean Paul
@ 2017-03-24  7:54   ` Jani Nikula
  2017-03-24 14:04     ` Sean Paul
  2017-04-03 21:10     ` [maintainer-tools PATCH v2 " Sean Paul
  2017-03-24  9:07   ` [PATCH dim " Ville Syrjälä
  1 sibling, 2 replies; 9+ messages in thread
From: Jani Nikula @ 2017-03-24  7:54 UTC (permalink / raw)
  To: Sean Paul, intel-gfx, ville.syrjala

On Thu, 23 Mar 2017, Sean Paul <seanpaul@chromium.org> wrote:
> Launch $EDITOR when extracting tags to curate the tags immediately. Once the
> tags are proper, automatically add them before the first Signed-off-by line
> to all patches in the range.

Two problems I have with this. First, I like to edit the final commit
message, not an intermediate file. Second, I pipe messages to dim
extract-tags *from* my $EDITOR, so I'd rather not have it launch $EDITOR
again.

BR,
Jani.

>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  dim | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/dim b/dim
> index 43ea794..6a5580a 100755
> --- a/dim
> +++ b/dim
> @@ -1145,6 +1145,12 @@ function rangeish()
>  	fi
>  }
>  
> +function insert_extracted_tags
> +{
> +	new_tabs=`cat $1 | awk '{ORS="\\\\n"} {print $0}' | head -c-3`
> +	awk "/Signed-off-by/{p++} p==1{print \"$new_tabs\"; p++} p!=1{print}"
> +}
> +
>  function dim_extract_tags
>  {
>  	local branch range file tags
> @@ -1167,9 +1173,10 @@ function dim_extract_tags
>  		return 0
>  	fi
>  
> -	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
> -
> -	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
> +	echo "$tags" > $file
> +	$EDITOR $file
> +	export -f insert_extracted_tags
> +	git filter-branch -f --msg-filter "insert_extracted_tags $file" $range
>  }
>  
>  function dim_extract_queued

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH dim 2/2] dim: Curate and insert tags into patch(es)
  2017-03-23 21:07 ` [PATCH dim 2/2] dim: Curate and insert tags into patch(es) Sean Paul
  2017-03-24  7:54   ` Jani Nikula
@ 2017-03-24  9:07   ` Ville Syrjälä
  2017-03-24 14:09     ` Sean Paul
  1 sibling, 1 reply; 9+ messages in thread
From: Ville Syrjälä @ 2017-03-24  9:07 UTC (permalink / raw)
  To: Sean Paul; +Cc: intel-gfx

On Thu, Mar 23, 2017 at 05:07:28PM -0400, Sean Paul wrote:
> Launch $EDITOR when extracting tags to curate the tags immediately. Once the
> tags are proper, automatically add them before the first Signed-off-by line
> to all patches in the range.

Not sure adding them before the first sob is the right thing. If we want
the tags to reflect the history somehow, then I suppose they should go
just before *your* sob, which may or may not be the first sob in the
commit message. Personally I've just started slapping them to the end
which also maintains the history, but granted it doesn't really show who
signed off on those tags. Or is there some "official" rule how tags
should be sorted in commit messages?

And I don't like the $EDITOR idea either, so at least make it
optional.

> 
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
>  dim | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/dim b/dim
> index 43ea794..6a5580a 100755
> --- a/dim
> +++ b/dim
> @@ -1145,6 +1145,12 @@ function rangeish()
>  	fi
>  }
>  
> +function insert_extracted_tags
> +{
> +	new_tabs=`cat $1 | awk '{ORS="\\\\n"} {print $0}' | head -c-3`
> +	awk "/Signed-off-by/{p++} p==1{print \"$new_tabs\"; p++} p!=1{print}"
> +}
> +
>  function dim_extract_tags
>  {
>  	local branch range file tags
> @@ -1167,9 +1173,10 @@ function dim_extract_tags
>  		return 0
>  	fi
>  
> -	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
> -
> -	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
> +	echo "$tags" > $file
> +	$EDITOR $file
> +	export -f insert_extracted_tags
> +	git filter-branch -f --msg-filter "insert_extracted_tags $file" $range
>  }
>  
>  function dim_extract_queued
> -- 
> 2.12.1.500.gab5fba24ee-goog

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH dim 2/2] dim: Curate and insert tags into patch(es)
  2017-03-24  7:54   ` Jani Nikula
@ 2017-03-24 14:04     ` Sean Paul
  2017-04-03 21:10     ` [maintainer-tools PATCH v2 " Sean Paul
  1 sibling, 0 replies; 9+ messages in thread
From: Sean Paul @ 2017-03-24 14:04 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx

On Fri, Mar 24, 2017 at 09:54:15AM +0200, Jani Nikula wrote:
> On Thu, 23 Mar 2017, Sean Paul <seanpaul@chromium.org> wrote:
> > Launch $EDITOR when extracting tags to curate the tags immediately. Once the
> > tags are proper, automatically add them before the first Signed-off-by line
> > to all patches in the range.
> 
> Two problems I have with this. First, I like to edit the final commit
> message, not an intermediate file. 

Hi Jani,
Thanks for your review.

The intermediate file includes just the extracted tags, not the entire commit
message. This allows you to reorder them as appropriate, or remove any false
positives before it hits the log.


> Second, I pipe messages to dim
> extract-tags *from* my $EDITOR, so I'd rather not have it launch $EDITOR
> again.
> 

The idea is that you approve the tags as soon as you extract them and saves you
having to commit --amend later to remove the "*** extracted tags ***" lines.
This can be meaningful if you've extracted tags to a large set, since you'd need
to go through each commit to make any necessary changes.

As Ville suggested, I can make the editor step optional (and restore the
"*** extracted tags ***" for the disabled case).

Sean



> BR,
> Jani.
> 
> >
> > Signed-off-by: Sean Paul <seanpaul@chromium.org>
> > ---
> >  dim | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/dim b/dim
> > index 43ea794..6a5580a 100755
> > --- a/dim
> > +++ b/dim
> > @@ -1145,6 +1145,12 @@ function rangeish()
> >  	fi
> >  }
> >  
> > +function insert_extracted_tags
> > +{
> > +	new_tabs=`cat $1 | awk '{ORS="\\\\n"} {print $0}' | head -c-3`
> > +	awk "/Signed-off-by/{p++} p==1{print \"$new_tabs\"; p++} p!=1{print}"
> > +}
> > +
> >  function dim_extract_tags
> >  {
> >  	local branch range file tags
> > @@ -1167,9 +1173,10 @@ function dim_extract_tags
> >  		return 0
> >  	fi
> >  
> > -	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
> > -
> > -	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
> > +	echo "$tags" > $file
> > +	$EDITOR $file
> > +	export -f insert_extracted_tags
> > +	git filter-branch -f --msg-filter "insert_extracted_tags $file" $range
> >  }
> >  
> >  function dim_extract_queued
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH dim 2/2] dim: Curate and insert tags into patch(es)
  2017-03-24  9:07   ` [PATCH dim " Ville Syrjälä
@ 2017-03-24 14:09     ` Sean Paul
  0 siblings, 0 replies; 9+ messages in thread
From: Sean Paul @ 2017-03-24 14:09 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

On Fri, Mar 24, 2017 at 11:07:17AM +0200, Ville Syrjälä wrote:
> On Thu, Mar 23, 2017 at 05:07:28PM -0400, Sean Paul wrote:
> > Launch $EDITOR when extracting tags to curate the tags immediately. Once the
> > tags are proper, automatically add them before the first Signed-off-by line
> > to all patches in the range.
> 
> Not sure adding them before the first sob is the right thing. If we want
> the tags to reflect the history somehow, then I suppose they should go
> just before *your* sob, which may or may not be the first sob in the
> commit message. Personally I've just started slapping them to the end
> which also maintains the history, but granted it doesn't really show who
> signed off on those tags. Or is there some "official" rule how tags
> should be sorted in commit messages?

Hi Ville,
Thanks for your review.

I usually sort them based on my perceived strength of the tag and put them
before the first SoB.

Cc:
Reviewed-by:
Tested-by:
Acked-by:
Signed-off-by:

I'm fine with putting them above the first SoB of the committer, that makes sense to
me. I'm not sure this is something we'll get consensus on, so that seems like a
sensible approach.

Sean

> 
> And I don't like the $EDITOR idea either, so at least make it
> optional.
> 
> > 
> > Signed-off-by: Sean Paul <seanpaul@chromium.org>
> > ---
> >  dim | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/dim b/dim
> > index 43ea794..6a5580a 100755
> > --- a/dim
> > +++ b/dim
> > @@ -1145,6 +1145,12 @@ function rangeish()
> >  	fi
> >  }
> >  
> > +function insert_extracted_tags
> > +{
> > +	new_tabs=`cat $1 | awk '{ORS="\\\\n"} {print $0}' | head -c-3`
> > +	awk "/Signed-off-by/{p++} p==1{print \"$new_tabs\"; p++} p!=1{print}"
> > +}
> > +
> >  function dim_extract_tags
> >  {
> >  	local branch range file tags
> > @@ -1167,9 +1173,10 @@ function dim_extract_tags
> >  		return 0
> >  	fi
> >  
> > -	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
> > -
> > -	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
> > +	echo "$tags" > $file
> > +	$EDITOR $file
> > +	export -f insert_extracted_tags
> > +	git filter-branch -f --msg-filter "insert_extracted_tags $file" $range
> >  }
> >  
> >  function dim_extract_queued
> > -- 
> > 2.12.1.500.gab5fba24ee-goog
> 
> -- 
> Ville Syrjälä
> Intel OTC

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [maintainer-tools PATCH v2 2/2] dim: Curate and insert tags into patch(es)
  2017-03-24  7:54   ` Jani Nikula
  2017-03-24 14:04     ` Sean Paul
@ 2017-04-03 21:10     ` Sean Paul
  2017-04-06 11:50       ` Jani Nikula
  1 sibling, 1 reply; 9+ messages in thread
From: Sean Paul @ 2017-04-03 21:10 UTC (permalink / raw)
  To: intel-gfx, ville.syrjala, jani.nikula

Launch $EDITOR when extracting tags to curate the tags immediately. Once the
tags are proper, automatically add them before the first Signed-off-by line
to all patches in the range.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
Changes in v2:
	- Append the tags before the committer's SoB (Ville)
	- Make launching $EDITOR contingent on -i flag (Ville/Jani)
	- Fix tty issues when launching editor


 dim | 44 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/dim b/dim
index 334882b..8b9a876 100755
--- a/dim
+++ b/dim
@@ -670,13 +670,23 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function get_committer_email
+{
+	local committer_email
+
+	if ! committer_email=$(git config --get user.email) ; then
+		committer_email=$EMAIL
+	fi
+	echo -n $committer_email
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
 dim_alias_sob=apply-branch
 function dim_apply_branch
 {
-	local branch file message_id commiter_email patch_from sob rv
+	local branch file message_id committer_email patch_from sob rv
 
 	branch=${1:?$usage}
 	shift
@@ -688,13 +698,10 @@ function dim_apply_branch
 	cat > $file
 
 	message_id=$(message_get_id $file)
-
-	if ! commiter_email=$(git config --get user.email) ; then
-		commiter_email=$EMAIL
-	fi
+	committer_email=$(get_committer_email)
 
 	patch_from=$(grep "From:" "$file" | head -1)
-	if [[ "$patch_from" != *"$commiter_email"* ]] ; then
+	if [[ "$patch_from" != *"$committer_email"* ]] ; then
 		sob=-s
 	fi
 
@@ -1156,6 +1163,15 @@ function rangeish()
 	fi
 }
 
+function insert_extracted_tags
+{
+	local committer_email new_tags sob
+	committer_email=$(get_committer_email)
+	new_tags=$(awk '{ORS="\\\\n"} {print $0}' $1 | head -c-3)
+	sob="Signed-off-by: .*<$committer_email>"
+	awk "/$sob/{p++} p==1{print \"$new_tags\"; p++} p!=1{print}"
+}
+
 function dim_extract_tags
 {
 	local branch range file tags
@@ -1177,9 +1193,19 @@ function dim_extract_tags
 		return 0
 	fi
 
-	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
-
-	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
+	# If interactive is selected, launch an editor to allow tag editing
+	# If it's not, just append the tags at the bottom of the commit
+	if [ "$INTERACTIVE" ]; then
+		echo "$tags" > $file
+		${EDITOR:-vi} $file >/dev/tty</dev/tty
+		export -f get_committer_email insert_extracted_tags
+		insert_extracted_tags $file >/dev/tty
+		cmd="insert_extracted_tags $file"
+	else
+		tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
+		cmd="cat ; echo \"$tags\""
+	fi
+	git filter-branch -f --msg-filter "$cmd" $range
 }
 
 function dim_extract_queued
-- 
2.12.2.715.g7642488e1d-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [maintainer-tools PATCH v2 2/2] dim: Curate and insert tags into patch(es)
  2017-04-03 21:10     ` [maintainer-tools PATCH v2 " Sean Paul
@ 2017-04-06 11:50       ` Jani Nikula
  2017-04-14 16:43         ` [maintainer-tools PATCH v3 " Sean Paul
  0 siblings, 1 reply; 9+ messages in thread
From: Jani Nikula @ 2017-04-06 11:50 UTC (permalink / raw)
  To: Sean Paul, intel-gfx, ville.syrjala


[Apologies, I thought I'd sent this, but it was in drafts...]

On Tue, 04 Apr 2017, Sean Paul <seanpaul@chromium.org> wrote:
> Launch $EDITOR when extracting tags to curate the tags immediately. Once the
> tags are proper, automatically add them before the first Signed-off-by line
> to all patches in the range.
>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
> Changes in v2:
> 	- Append the tags before the committer's SoB (Ville)
> 	- Make launching $EDITOR contingent on -i flag (Ville/Jani)
> 	- Fix tty issues when launching editor
>
>
>  dim | 44 +++++++++++++++++++++++++++++++++++---------
>  1 file changed, 35 insertions(+), 9 deletions(-)
>
> diff --git a/dim b/dim
> index 334882b..8b9a876 100755
> --- a/dim
> +++ b/dim
> @@ -670,13 +670,23 @@ function dim_push_fixes
>  	dim_push_branch drm-intel-fixes "$@"
>  }
>  
> +function get_committer_email
> +{
> +	local committer_email
> +
> +	if ! committer_email=$(git config --get user.email) ; then
> +		committer_email=$EMAIL
> +	fi
> +	echo -n $committer_email
> +}
> +
>  # ensure we're on branch $1, and apply patches. the rest of the arguments are
>  # passed to git am.
>  dim_alias_ab=apply-branch
>  dim_alias_sob=apply-branch
>  function dim_apply_branch
>  {
> -	local branch file message_id commiter_email patch_from sob rv
> +	local branch file message_id committer_email patch_from sob rv
>  
>  	branch=${1:?$usage}
>  	shift
> @@ -688,13 +698,10 @@ function dim_apply_branch
>  	cat > $file
>  
>  	message_id=$(message_get_id $file)
> -
> -	if ! commiter_email=$(git config --get user.email) ; then
> -		commiter_email=$EMAIL
> -	fi
> +	committer_email=$(get_committer_email)
>  
>  	patch_from=$(grep "From:" "$file" | head -1)
> -	if [[ "$patch_from" != *"$commiter_email"* ]] ; then
> +	if [[ "$patch_from" != *"$committer_email"* ]] ; then
>  		sob=-s
>  	fi
>  
> @@ -1156,6 +1163,15 @@ function rangeish()
>  	fi
>  }
>  
> +function insert_extracted_tags
> +{
> +	local committer_email new_tags sob
> +	committer_email=$(get_committer_email)
> +	new_tags=$(awk '{ORS="\\\\n"} {print $0}' $1 | head -c-3)
> +	sob="Signed-off-by: .*<$committer_email>"
> +	awk "/$sob/{p++} p==1{print \"$new_tags\"; p++} p!=1{print}"
> +}
> +
>  function dim_extract_tags
>  {
>  	local branch range file tags
> @@ -1177,9 +1193,19 @@ function dim_extract_tags
>  		return 0
>  	fi
>  
> -	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
> -
> -	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
> +	# If interactive is selected, launch an editor to allow tag editing
> +	# If it's not, just append the tags at the bottom of the commit
> +	if [ "$INTERACTIVE" ]; then

Sorry, interactive doesn't do what you think it does. It just
pauses. Blame Daniel. ;)

Which again means that this will fail for my workflow. :(

> +		echo "$tags" > $file
> +		${EDITOR:-vi} $file >/dev/tty</dev/tty

Why vi? Why the redirects?

BR,
Jani.

> +		export -f get_committer_email insert_extracted_tags
> +		insert_extracted_tags $file >/dev/tty
> +		cmd="insert_extracted_tags $file"
> +	else
> +		tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
> +		cmd="cat ; echo \"$tags\""
> +	fi
> +	git filter-branch -f --msg-filter "$cmd" $range
>  }
>  
>  function dim_extract_queued

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [maintainer-tools PATCH v3 2/2] dim: Curate and insert tags into patch(es)
  2017-04-06 11:50       ` Jani Nikula
@ 2017-04-14 16:43         ` Sean Paul
  0 siblings, 0 replies; 9+ messages in thread
From: Sean Paul @ 2017-04-14 16:43 UTC (permalink / raw)
  To: intel-gfx, ville.syrjala, jani.nikula

Launch $EDITOR when extracting tags to curate the tags immediately. Once the
tags are proper, automatically add them before the committer's Signed-off-by line
to all patches in the range.

Changes in v2:
- Append the tags before the committer's SoB (Ville)
- Make launching $EDITOR contingent on -i flag (Ville/Jani)
- Fix tty issues when launching editor

Changes in v3:
- Don't overload interactive mode (add new edit mode) (Jani)
- Don't default to vi, use non-edit mode if EDITOR not set (Jani)
- Fix newline escaping in insert_extracted_tags

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 dim     | 49 +++++++++++++++++++++++++++++++++++++++----------
 dim.rst |  5 +++++
 2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/dim b/dim
index 750f737..d791df3 100755
--- a/dim
+++ b/dim
@@ -144,13 +144,17 @@ INTERACTIVE=
 DRY=
 FORCE=
 HELP=
+EDIT=
 
-while getopts hdfis opt; do
+while getopts hdefis opt; do
 	case "$opt" in
 		d)
 			DRY_RUN=--dry-run
 			DRY=echo
 			;;
+		e)
+			EDIT=1
+			;;
 		f)
 			FORCE=1
 			;;
@@ -670,13 +674,23 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function get_committer_email
+{
+	local committer_email
+
+	if ! committer_email=$(git config --get user.email) ; then
+		committer_email=$EMAIL
+	fi
+	echo -n $committer_email
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
 dim_alias_sob=apply-branch
 function dim_apply_branch
 {
-	local branch file message_id commiter_email patch_from sob rv
+	local branch file message_id committer_email patch_from sob rv
 
 	branch=${1:?$usage}
 	shift
@@ -688,13 +702,10 @@ function dim_apply_branch
 	cat > $file
 
 	message_id=$(message_get_id $file)
-
-	if ! commiter_email=$(git config --get user.email) ; then
-		commiter_email=$EMAIL
-	fi
+	committer_email=$(get_committer_email)
 
 	patch_from=$(grep "From:" "$file" | head -1)
-	if [[ "$patch_from" != *"$commiter_email"* ]] ; then
+	if [[ "$patch_from" != *"$committer_email"* ]] ; then
 		sob=-s
 	fi
 
@@ -1213,6 +1224,15 @@ function rangeish()
 	fi
 }
 
+function insert_extracted_tags
+{
+	local committer_email new_tags sob
+	committer_email=$(get_committer_email)
+	new_tags=$(awk '{ORS="\\n"} {print $0}' $1 | head -c-3)
+	sob="Signed-off-by: .*<$committer_email>"
+	awk "/$sob/{p++} p==1{print \"$new_tags\"; p++} p!=1{print}"
+}
+
 function dim_extract_tags
 {
 	local branch range file tags
@@ -1234,9 +1254,18 @@ function dim_extract_tags
 		return 0
 	fi
 
-	tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
-
-	git filter-branch -f --msg-filter "cat ; echo \"$tags\"" $range
+	# If edit is selected, launch an editor to allow tag editing
+	# If it's not, just append the tags at the bottom of the commit
+	if [ "$EDIT" ] && [ -n $EDITOR ]; then
+		echo "$tags" > $file
+		$EDITOR $file >/dev/tty</dev/tty
+		export -f get_committer_email insert_extracted_tags
+		cmd="insert_extracted_tags $file"
+	else
+		tags=$(printf -- "# *** extracted tags ***\n%s" "$tags")
+		cmd="cat ; echo \"$tags\""
+	fi
+	git filter-branch -f --msg-filter "$cmd" $range
 }
 
 function dim_extract_queued
diff --git a/dim.rst b/dim.rst
index 3dd19f9..71c09ee 100644
--- a/dim.rst
+++ b/dim.rst
@@ -96,6 +96,7 @@ OPTIONS
 
 -f		Ignore some error conditions.
 -d		Dry run.
+-e		Edit mode.
 -i		Interactive mode.
 
 COMMANDS
@@ -204,6 +205,10 @@ This extracts various tags (e.g. Reviewed-by:) from emails and applies them to t
 top commit on the given branch. You can give the command a rangeish to add the
 tags from the same email to multiple already applied patches.
 
+Use the -e argument to launch $EDITOR, allowing you to immediately edit the
+extracted tags. Once finished, the tags will be inserted above your
+Signed-off-by tag.
+
 extract-fixes [*git-rangeish*]
 ------------------------------
 
-- 
2.12.2.762.g0e3151a226-goog

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-04-14 16:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-23 21:07 [PATCH dim 1/2] dim: Add support for multiple messages in extract-tags Sean Paul
2017-03-23 21:07 ` [PATCH dim 2/2] dim: Curate and insert tags into patch(es) Sean Paul
2017-03-24  7:54   ` Jani Nikula
2017-03-24 14:04     ` Sean Paul
2017-04-03 21:10     ` [maintainer-tools PATCH v2 " Sean Paul
2017-04-06 11:50       ` Jani Nikula
2017-04-14 16:43         ` [maintainer-tools PATCH v3 " Sean Paul
2017-03-24  9:07   ` [PATCH dim " Ville Syrjälä
2017-03-24 14:09     ` Sean Paul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.