[Intel-gfx] [maintainer-tools PATCH v2 2/2] dim: Curate and insert tags into patch(es)
Jani Nikula
jani.nikula at linux.intel.com
Thu Apr 6 11:50:47 UTC 2017
[Apologies, I thought I'd sent this, but it was in drafts...]
On Tue, 04 Apr 2017, Sean Paul <seanpaul at 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 at 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
More information about the Intel-gfx
mailing list