#!/bin/bash

# retitle an RFP/O bug to ITP/ITA
#
# Copyright 2010 gregor herrmann <gregoa@debian.org>
# Copyright 2013 Damyan Ivanov <dmn@debian.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.


usage() {
	echo "Usage: $(basename $0) <bug number> <ITP|ITA>"
	exit 1
}

[ $# == 2 ] || usage

BUG="$1"
NEW="$2"

SUBJECT=$(bts status "$BUG" | perl -ne "print if s/subject\s(.+)/\1/ && s/^\w+:/${NEW}:/")

echo "run the following command?"
echo bts retitle "$BUG" "$SUBJECT" . owner "$BUG" \!
read -n 1 -p "y/N" SEND
if [ "$SEND" == "y" ] ; then
	bts retitle "$BUG" "$SUBJECT" . owner "$BUG" \!
fi

exit 0

POD=<<EOF
=head1 NAME

bts-retitle -- note your intention to package a RFP/adopt a RFA

=head1 SYNOPSIS

B<bts-retitle> I<bug number> ITP

B<bts-retitle> I<bug-number> ITA

=head1 DESCRIPTION

B<bts-retitle> is a small wrapper around the L<bts(1)> command for easy
changing the C<RFP>/C<RFA> prefix of a bug report in the Debian bug tracking
system to C<ITP>/C<ITA>.

B<bts-retitle> also sets the owner of the bug report to the current user, after
asking for confirmation.

=head1 CAVEATS

=over

=item Working local mail setup required

Since B<bts-retitle> uses L<bts(1)>, it requires that the local machine has a
working mail setup and is able to send mails to the Debian bug tracking system.

=back

=head1 INVENTORY

=over

=item RFP

Request for a package

=item RFA

Request for adoption of a package

=item ITP

Intent to package

=item ITA

Intent to adopt a package

=back

=head1 COPYRIGHT & LICENSE

Copyright 2010 gregor herrmann <gregoa@debian.org>
Copyright 2013 Damyan Ivanov <dmn@debian.org>

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut
EOF
