#!/usr/bin/perl -w

use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Test::Repocop::Common;
use Test::Repocop::Options;
use Test::Repocop::Metadata;

my $column=1;

&Test::Repocop::Options::get_common_options(
    "column=i"  => \$column,
);
#my $result = GetOptions (
#    @Test::Repocop::Options::LONGOPT,
#);

#if ($help) {
#    pod2usage();
#}

my $metadata=Test::Repocop::Metadata->new();
# in perl, column counting is from 0.
$column--;
while (<>) {
    my @line=split(/\s+/,$_);
    my $patch=$line[$column];
    next unless $patch; # empty line ?
    my $id=&Test::Repocop::Common::patchname2srcid($patch);
    my $name=$metadata->name($id);
    if (not $name) {
	warn "$patch: name not found\n";
	next;
    }
    print STDERR "name=$name patch: $patch\n" if $Test::Repocop::Options::verbose;
    print $name."\t$_";
}

=head1	NAME

repocop-filter-list-diff-prepend-name - prepend src.rpm name to the list of repocop patches.

=head1	SYNOPSIS

B<repocop-filter-list-diff-prepend-name>
[B<-h|--help>]
[B<-q|--quiet>]
[B<-v|--verbose>]
[B<-c|--column> I<N>]

=head1	DESCRIPTION

B<repocop-filter-list-prepend-name> 

=head1	OPTIONS

=over

=item	B<-h, --help>

Display this help and exit.

=item	B<-c, --column> I<N>

The column containing source rpm patch (counting from 1).

=item	B<-v, --verbose>, B<-q, --quiet>

Verbosity level. Multiple -v increase the verbosity level, -q sets it to 0.

=back

=head1	AUTHOR

Written by Igor Vlasenko <viy@altlinux.org>.

=head1	COPYING

Copyright (c) 2012 Igor Vlasenko, ALT Linux Team.

This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

=cut
