#!perl

use strict;
use warnings;

use Git::CPAN::Patch::Import;

use Getopt::Long;
use Pod::Usage;

my %opt = ( checkversion => 1 );

GetOptions( \%opt, 
    'help' => sub { pod2usage(1) },
    'man'  => sub { pod2usage( verbose => 2 ) },
    'backpan!', 
    'checkversion!',
    'parent:s@',
    'gitpan!',
) 
    or pod2usage( 
        "for a list of all valid options, do 'git cpan-import --help'" 
    );

$| = 1;

my $module;
if ( @ARGV ) {
    # if there's an arg explicitly import something (could be an update to an
    # old version or an initial import)
    $module = shift;
}

Git::CPAN::Patch::Import::main( $module, \%opt );


__END__

=pod

=head1 NAME

git-cpan-import - Import a module into a git repository

=head1 VERSION

version 0.4.3

=head1 SYNOPSIS

    # takes any string CPANPLUS handles:

    % git cpan-import Foo::Bar
    % git cpan-import A/AU/AUTHORID/Foo-Bar-0.03.tar.gz
    % git cpan-import http://backpan.cpan.org/authors/id/A/AU/AUTHORID/Foo-Bar-0.03.tar.gz



    # If the repository is already initialized, can be run with no arguments to
    # import the latest version
    git cpan-import


=head1 DESCRIPTION

This command is used internally by C<git-cpan-init>, C<git-cpan-update> and
C<git-backpan-init>.

This command takes a tarball, extracts it, and imports it into the repository.

It is only possible to update to a newer version of a module.

The module history is tracked in C<refs/remotes/cpan/master>.

Tags are created for each version of the module.

This command does not touch the working directory, and is safe to run even if
you have pending work.

=head1 OPTIONS

=over

=item  --backpan

Enables Backpan index fetching (to get the author and release date).

=item --gitpan

Imports the distribution's gitpan repository 
under the remote branch I<gitpan>.  Subsequent calls with this option are
equivalent to a simple C<git fetch gitpan>.

=item --checkversion, --nocheckversion

Explicitly enables/disables version checking.  If version checking is
enabled, which is the default, git-cpan-import will refuse to import a 
version of the package
that has a smaller version number than the HEAD of the branch I<cpan/master>.

=item --parent

Allows adding extra parents when
importing, so that when a patch has been incorporated into an upstream
version the generated commit is like a merge commit, incorporating both
the CPAN history and the user's local history.

For example, this will set the current HEAD of the master branch as a parent of 
the imported CPAN package:

	$ git checkout master
	$ git cpan-import --parent HEAD My-Module

More than one '--parent' can be specified.

=back

=head1 BUGS AND LIMITATIONS

Please report any bugs or feature requests to
C<bug-git-cpan-patch@rt.cpan.org>, or through the web 
interface at L<http://rt.cpan.org>.
  
=head1 AUTHORS

Yuval Kogman C<< <nothingmuch@woobling.org> >>

Yanick Champoux C<< <yanick@cpan.org> >>

=head1 LICENCE

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

=head1 SEE ALSO

L<Git::CPAN::Patch>

The gitpan GitHub account at L<http://github.com/gitpan>.

=cut