diff mbox

[maintainer-tools] dim: Add pull request tag headers

Message ID 20170502145550.1010-1-seanpaul@chromium.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Paul May 2, 2017, 2:55 p.m. UTC
Add some standard headers to the pull request tag annotation.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 dim     | 25 ++++++++++++++++++++++++-
 dim.rst |  4 ++++
 2 files changed, 28 insertions(+), 1 deletion(-)

Comments

Sean Paul May 2, 2017, 2:58 p.m. UTC | #1
On Tue, May 2, 2017 at 10:55 AM, Sean Paul <seanpaul@chromium.org> wrote:
> Add some standard headers to the pull request tag annotation.
>
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---

This time to Daniel's actual address.

Note that I couldn't add the headers as comments since git tag -m
skips anything prefixed with #. Hopefully having the ability to
override the headers makes up for this.

Sean

>  dim     | 25 ++++++++++++++++++++++++-
>  dim.rst |  4 ++++
>  2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/dim b/dim
> index 8937803..0d52e9d 100755
> --- a/dim
> +++ b/dim
> @@ -67,6 +67,9 @@ DIM_TEMPLATE_HELLO=${DIM_TEMPLATE_HELLO:-$HOME/.dim.template.hello}
>  # signature pull request template
>  DIM_TEMPLATE_SIGNATURE=${DIM_TEMPLATE_SIGNATURE:-$HOME/.dim.template.signature}
>
> +# pull request headers template
> +DIM_TEMPLATE_PULL_HEADERS=${DIM_TEMPLATE_PULL_HEADERS:-$HOME/.dim.template.pullheaders}
> +
>  #
>  # Internal configuration.
>  #
> @@ -1501,10 +1504,28 @@ function dim_tag_next
>
>  }
>
> +function prep_pull_tag_headers
> +{
> +       local template
> +
> +       if [ -r $DIM_TEMPLATE_PULL_HEADERS ]; then
> +               while read -r m || [[ -n "$line" ]]; do
> +                       template="$template -m '$m'"
> +               done < "$DIM_TEMPLATE_PULL_HEADERS"
> +       else
> +               template="-m 'UABI Changes:'"
> +               template="$template -m 'Cross-subsystem Changes:'"
> +               template="$template -m 'Core Changes:'"
> +               template="$template -m 'Driver Changes:'"
> +       fi
> +       echo $template
> +}
> +
>  # dim_pull_request branch upstream
>  function dim_pull_request
>  {
>         local branch upstream remote repo req_file url git_url suffix tag
> +       local tag_headers
>
>         branch=${1:?$usage}
>         upstream=${2:?$usage}
> @@ -1535,7 +1556,9 @@ function dim_pull_request
>                 done
>
>                 gitk "$branch@{upstream}" ^$upstream &
> -               $DRY git tag -a $tag "$branch@{upstream}"
> +               tag_headers=$(prep_pull_tag_headers)
> +               $DRY git tag $tag_headers $tag "$branch@{upstream}"
> +               $DRY git tag -a -f $tag
>                 $DRY git push $remote $tag
>                 prep_pull_mail $req_file $tag
>
> diff --git a/dim.rst b/dim.rst
> index 3dd19f9..02a7a55 100644
> --- a/dim.rst
> +++ b/dim.rst
> @@ -464,6 +464,10 @@ DIM_TEMPLATE_SIGNATURE
>  ----------------------
>  Path to a file containing a signature template for pull request mails.
>
> +DIM_TEMPLATE_PULL_HEADERS
> +-------------------------
> +Path to a file containing pull request headers, each on their own line.
> +
>  dim_alias_<alias>
>  -----------------
>  Make **<alias>** an alias for the subcommand defined as the value. For example,
> --
> 2.13.0.rc1.294.g07d810a77f-goog
>
diff mbox

Patch

diff --git a/dim b/dim
index 8937803..0d52e9d 100755
--- a/dim
+++ b/dim
@@ -67,6 +67,9 @@  DIM_TEMPLATE_HELLO=${DIM_TEMPLATE_HELLO:-$HOME/.dim.template.hello}
 # signature pull request template
 DIM_TEMPLATE_SIGNATURE=${DIM_TEMPLATE_SIGNATURE:-$HOME/.dim.template.signature}
 
+# pull request headers template
+DIM_TEMPLATE_PULL_HEADERS=${DIM_TEMPLATE_PULL_HEADERS:-$HOME/.dim.template.pullheaders}
+
 #
 # Internal configuration.
 #
@@ -1501,10 +1504,28 @@  function dim_tag_next
 
 }
 
+function prep_pull_tag_headers
+{
+	local template
+
+	if [ -r $DIM_TEMPLATE_PULL_HEADERS ]; then
+		while read -r m || [[ -n "$line" ]]; do
+			template="$template -m '$m'"
+		done < "$DIM_TEMPLATE_PULL_HEADERS"
+	else
+		template="-m 'UABI Changes:'"
+		template="$template -m 'Cross-subsystem Changes:'"
+		template="$template -m 'Core Changes:'"
+		template="$template -m 'Driver Changes:'"
+	fi
+	echo $template
+}
+
 # dim_pull_request branch upstream
 function dim_pull_request
 {
 	local branch upstream remote repo req_file url git_url suffix tag
+	local tag_headers
 
 	branch=${1:?$usage}
 	upstream=${2:?$usage}
@@ -1535,7 +1556,9 @@  function dim_pull_request
 		done
 
 		gitk "$branch@{upstream}" ^$upstream &
-		$DRY git tag -a $tag "$branch@{upstream}"
+		tag_headers=$(prep_pull_tag_headers)
+		$DRY git tag $tag_headers $tag "$branch@{upstream}"
+		$DRY git tag -a -f $tag
 		$DRY git push $remote $tag
 		prep_pull_mail $req_file $tag
 
diff --git a/dim.rst b/dim.rst
index 3dd19f9..02a7a55 100644
--- a/dim.rst
+++ b/dim.rst
@@ -464,6 +464,10 @@  DIM_TEMPLATE_SIGNATURE
 ----------------------
 Path to a file containing a signature template for pull request mails.
 
+DIM_TEMPLATE_PULL_HEADERS
+-------------------------
+Path to a file containing pull request headers, each on their own line.
+
 dim_alias_<alias>
 -----------------
 Make **<alias>** an alias for the subcommand defined as the value. For example,