Re: Proposed hook to tag bugs as pending
On Thu, Mar 26 2009, Adeodato Simó wrote:
>
> “Oh.” I guess such workflow was already implied in John’s message, but I
> parsed his “git-buildpackage tools can generate an appropriate changelog
> for you” as to mean that they’d generate the corresponding
> debian/changelog entry *on each commit*, whereas he problably meant (or
> at least you are now, AIUI) generating the full debian/changelog before
> the upload, from all the existing commit messages since the last tag.
> This is a workflow I actually knew existed, but failed to recall today,
> hence my EPIC FAIL above.
> Now, if one wanted to write a hook that actually catered for both
> workflows, what would one do? Does anybody has suggestions? It is
> certainly doable to parse the commit message for Closes, and act only on
> those bugs if any, and if there are not any, look at the changelog. (I
> think it’s reasonable not looking at debian/changelog it the commit
> message mentions a bug number.)
> However, this will behave horribly when the run of git-dch or whatever
> tool is committed, since it will want to mark all the bugs as pending
> again; that’s the part where I need suggestions. I’d rather not have the
> hook need any configuration, and making it stateful is definitely out of
> questions. Maybe it should treat the bug numbers from debian/changelog
> as “untrusted”, and only send the message if they are not tagged pending
> already (by doing a SOAP request)?
>
> Thoughts? (And thanks for pointing out this.)
I have a hook script that looks at each commit and sets the bugs
to pending. This allows me to make fixes on the non-master branch; and
the bugs gets marked pending when the fix goes in. Later, all the
branches get merged into the master; and then I generate changelog. I
have not noticed dch trying to mark bugs pending again when I run it;
though.
manoj
#! /bin/zsh -f
# Details of the most recent commit
commit_full_hash=$(git log -1 --pretty=format:%H)
commit_hash=$(git log -1 --pretty=format:%h)
commit_author_name=$(git log -1 --pretty=format:%an)
commit_author_email=$(git log -1 --pretty=format:%ae)
commit_date=$(git log -1 --pretty=format:%cD)
commit_subject=$(git log -1 --pretty=format:%s)
commit_changes=$(git log -1 --pretty=format:%b)
escaped_message=$(git log -1 --pretty=format:%b | \
sed -e 's,&,&,g' -e 's,<,<,g' -e 's,>,>,g')
# Details about this branch:
refname=$(git symbolic-ref HEAD 2>/dev/null)
refname=${refname##refs/heads/}
merged=$(git rev-parse HEAD)
rev=$(git describe ${merged} 2>/dev/null)
sendmail_wrapper()
{
if [ $# -ne 3 ] ; then
echo 1>&2 "sendmail usage error: need 3 arguments"
exit 1
fi
if [ "$1" != "-s" ] ; then
echo 1>&2 "sendmail usage error: first argument must be -s"
exit 1
fi
(
cat <<EOF
To: $3
Message-ID: <${rev}@${commit_full_hash}>
BCC: srivasta@debian.org
Subject: $2
X-PTS-Approved: Yes
EOF
cat
) | /usr/sbin/sendmail -oi -t
}
# replace the call to /usr/sbin/sendmail -oi -t by: tee /tmp/junk
echo "$commit_changes" | perl -e '
my %Seen;
{
local $/; # enable localized slurp mode
my $string=<>;
while ( $string =~ m/closes:\s*(?:bug)?\#\s*\d+(?:,\s*(?:bug)?\#\s*\d+)*/gsmi ) {
my $match="$&";
while ($match =~ /(\d+)/g) {
$Seen{$1}++;
}
}
}
for (sort keys %Seen) { print "$_\n"; }
' | while read bug; do
echo | \
sendmail_wrapper -s "[$commit_hash] Fix for Bug#$bug committed to git" \
$bug@bugs.debian.org,control@bugs.debian.org<<EOF
tags $bug +pending
thanks
Hi,
The following change has been committed for this bug by
$commit_author_name <$commit_author_email> on $commit_date.
The fix will be in the next upload.
=========================================================================
$commit_subject
$commit_changes
=========================================================================
EOF
done
--
"It takes all sorts of in & out-door schooling to get adapted to my kind
of fooling"- R. Frost
Manoj Srivastava <srivasta@debian.org> <http://www.debian.org/~srivasta/>
1024D/BF24424C print 4966 F272 D093 B493 410B 924B 21BA DABB BF24 424C
Reply to: