Adding Reviewed-by (and the like) tags

Daniel Stone daniel at fooishbar.org
Thu May 5 08:46:58 PDT 2011


Hi,

On Thu, May 05, 2011 at 05:01:06PM +0200, Cyril Brulebois wrote:
> git filter-branch --msg-filter 'add-tag.sh "Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>" "Reviewed-by: Daniel Stone <daniel at fooishbar.org>"' origin/master..

Or, in ~/.gitconfig:
[aliases]
    addrb = filter-branch --msg-filter ~/bin/add-r-b

And my version of the script, which works with short entries, tries to
preserve order as much as possible, and defaults to adding a Reviewed-by
tag with your identity if no arguments are given:

<---
#!/bin/sh

if [ -n "$GIT_AUTHOR_NAME" ] && [ -n "$GIT_AUTHOR_EMAIL" ]; then
    MY_ID="$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>"
elif [ -n "$(git config --get user.name)" ] &&
     [ -n "$(git config --get user.email)" ]; then
    MY_ID="$(git config --get user.name) <$(git config --get user.email)>"
fi

ARGS=$@
if [ -z "$ARGS" ] && [ -n "$MY_ID" ]; then
    ARGS="Reviewed-by: $MY_ID"
fi

# Build the awk command line, reverse param orders:
cmd=
for i in "$ARGS"; do
  cmd="print \"$i\"; $cmd"
done

# Insert lines after the first/last empty line:
cat | awk \
   "BEGIN {
        needs_blank=1
    };
    /Signed-off-by/ || /Reviewed-by/ || /Tested-by/ || /Reported-by/ {
        needs_blank=0
    };
    {
        print
    };
    END {
        if (needs_blank) {
            print \"\"
        }
        $cmd
    };"

--->

Cheers,
Daniel


More information about the xorg-devel mailing list