#!/usr/bin/perl -w

use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use Gear::Remotes::Watch;

my $action='gear-uupdate';
my $verbose=1;
my ($help);

my $result = GetOptions (
    'verbose+' => \$verbose,
    'q|quiet'  => sub {$verbose=0},
    'h|help'   => \$help,
    'action=s'   => \$action,
    );

pod2usage(-verbose => 2) if $help;

&Gear::Remotes::Watch::watch_remotes(
    -action => $action,
    -verbose => $verbose,
    );

=head1	NAME

gear-remotes-uscan - update to new version if found in git repo listed in .gear/upstream/remotes file

=head1	SYNOPSIS

B<gear-remotes-uscan>

=head1	DESCRIPTION

B<gear-remotes-uscan> is like B<gear-remotes-watch>, but if a new version is found
it calls gear-uupdate to perform gear repository update instead of issuing a notification. 

It first checks for updates in foreign upstream git repository(ies) 
listed in I<.gear/upstream/remotes> file. For that B<gear-remotes-uscan>
lists tags available in upstream git repository and compares them with the current
version in spec file. If a tag with greater version is found,
it calls gear-uupdate with correct options to perform gear repository update.

B<gear-remotes-uscan> uses the following auxiliary scripts, if found and
if they are executable: B<.gear/upstream/filter-tag> is used to separate release tags
from all tags found, and B<.gear/upstream/transform-tag> is used to transform
custom tags like RELEASE_1_0_1 to rpm version compatible look like 1.0.1.
In other words, after you fetch remote commits, you should get a list of available
upstream versions using
 git tag | .gear/upstream/filter-tag | .gear/upstream/transform-tag

=head1	OPTIONS

=over

=item	B<-h, --help>

Display this help and exit.

=item	B<--action I<cmd>>

Call I<cmd> instead of gear-uupdate.

=item	B<-v, --verbose>

Increase verbosity level.

=item	B<-q, --quiet>

Quiet mode.

=back

=head1	AUTHOR

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

=head1	COPYING

Copyright (c) 2014-2021 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

