Adding Reviewed-by (and the like) tags

Cyril Brulebois kibi at debian.org
Thu May 5 08:01:06 PDT 2011


Hi,

I guess it might be worth mentioning somewhere in the wiki how to
easily (in an automated fashion) add r-b tags to a range of
commits. Following Jon's suggestion on IRC, I've opted for:

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..

(You may want to pass -f if you play with it several times in a row.)

add-tag.sh:
--o<--o<--o<--
#!/bin/sh

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

# Insert lines after the first/last empty line:
tac|awk "BEGIN { done=0 }; /^$/ { if (done < 1) $cmd ; done=1 }; { print };"|tac
-->o-->o-->o--

Seems to work fine for a few examples; and can easily be tweaked to
learn about usual tag aliases (r-b et al.), and possibly people
aliases (peter, daniels, etc.).

Or just put everything in a file (letting your editor deal with alias
expansion), and replace the first part of the “script” with a while
read loop on that file's contents.

That could become:
  git filter-branch -f --msg-filter "add-tag-two.sh $(pwd)/.rb"  origin/master..

add-tag-two.sh:
--o<--o<--o<--
#!/bin/sh

# Make sure the file exists:
tagfile=$1
if [ -z "$tagfile" -o ! -f $tagfile ]; then
    echo "E: Missing tag file ($tagfile); cwd=$(pwd)" >&2
    exit 1
fi

# Build the awk command line, reverse line orders:
cmd=
while read line; do
  cmd="print \"$line\"; $cmd"
done < $tagfile

# Insert lines after the last empty line:
tac|awk "BEGIN { done=0 }; /^$/ { if (done < 1) $cmd ; done=1 }; { print };"|tac
-->o-->o-->o--

The pitfall is that cwd points to .git-rewrite/t when that script is
run, so passing just '.rb' would fail.

Mraw,
KiBi.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110505/f9d514fb/attachment.pgp>


More information about the xorg-devel mailing list