[PATCH] Missing acks should only be fatal on primary branch

Vratislav Podzimek vpodzime at redhat.com
Wed Sep 18 10:02:12 UTC 2013


On Tue, 2013-09-17 at 09:37 -0700, Brian C. Lane wrote:
> From: "Brian C. Lane" <bcl at redhat.com>
> 
> Previous patch wasn't fatal at all, and only checked for rhelX-branch.
> The commit-msg hook doesn't run when cherry-picking which is usually how
> I move things over to the primary branch after acks are granted.
> 
> This makes commits on non -branch branches starting with rhelX- just a
> warning. And if you do happen to commit on the primary it will be fatal.
> 
> I haven't figured out a way to hook cherry-picks yet, so this will have
> to do for now.
> 
> (note this will be squashed with the previous and this commentary
> removed)
> ---
>  scripts/githooks/commit-msg | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg
> index aa3a93e..8fa2f8d 100755
> --- a/scripts/githooks/commit-msg
> +++ b/scripts/githooks/commit-msg
> @@ -24,12 +24,21 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
>  RETVAL=0
>  
>  branch_name=$(git branch | grep ^* | cut -c3-)
> -branch_pattern="^rhel([[:digit:]])-branch"
> +branch_pattern="^rhel([[:digit:]])-(.*)"
>  if [[ ! "$branch_name" =~ $branch_pattern ]]; then
>      exit ${RETVAL}
>  fi
>  RELEASE=${BASH_REMATCH[1]}
>  
> +# Is this a local branch, or the primary branch?
> +if [ "${BASH_REMATCH[2]}" == "branch" ]; then
> +    # Make a missing ack block the commit
> +    ACK_FATAL=1
> +else
> +    # Missing acks are just warnings
> +    ACK_FATAL=0
> +fi
> +
>  if [ -f "${HOME}/.rhbzauth" ]; then
>      . "${HOME}/.rhbzauth"
>  fi
> @@ -53,6 +62,8 @@ else
>      ${bzcmd} login
>  fi
>  
> +# Check the bz to see if it has an ack for this release. If the branch is
> +# a local branch, just warn. If it is the primary branch, block the commit.
>  bz_has_ack() {
>      bug=$1
>      flags=$(${bzcmd} query --bug_id=${bug} --outputformat="%{flags}")
> @@ -60,6 +71,10 @@ bz_has_ack() {
>      ack_pattern="rhel-${RELEASE}\.[[:digit:]]+\.[[:digit:]]+\+"
>      if [[ ! "$flags" =~ $ack_pattern ]]; then
>          echo "*** BZ ${bug} is missing acks: ${flags}"
> +
> +        if [ $ACK_FATAL -eq 1 ]; then
> +            RETVAL=1
> +        fi
>      fi
>  }
>  
Nice improvement, ACK.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list