Github-Import
view release on metacpan or search on metacpan
lib/Github/Import.pm view on Meta::CPAN
}
return $uri->scheme . '://github.com/' . $self->github_path;
};
sub run_git {
my ( $self, @args ) = @_;
unshift @args, "command" if @args % 2;
my %args = @args;
my ( $command, $print_output ) = @args{qw(command print_output)};
if ( $self->dry_run ) {
$self->msg("git @$command");
} else {
my $method = $print_output ? "command_noisy" : "command";
$self->git_handle->$method(@$command);
}
}
sub do_add_remote {
my $self = shift;
my $remote = $self->remote;
my $push = $self->push_uri;
if ( defined( my $url = $self->_conf_var("remote.${remote}.url") ) ) {
if ( $url ne $push ) {
$self->err("remote $remote is already configured as $url");
} else {
$self->msg("remote $remote already added");
}
} else {
$self->run_git(
[qw(remote add), $remote, $push],
);
$self->run_git(
[qw(config github.repo), $self->project_name],
);
}
}
sub do_push {
my $self = shift;
my $remote = $self->add_remote ? $self->remote : $self->push_uri;
my $refspec = $self->refspec;
my @args = $self->has_push_mode
? ( "--" . $self->push_mode, $self->remote )
: ( $self->push_tags ? "--tags" : (), $remote, $self->refspec );
$self->run_git(
[ push => @args ],
print_output => 1,
);
}
sub update_config_for_pull {
my $self = shift;
my $remote = $self->remote;
$self->run_git(
[ config => 'branch.master.remote', $remote ],
);
$self->run_git(
[ config => 'branch.master.merge', 'refs/heads/master' ],
);
# if the standard option branch.autosetuprebase is set, then we do
# the same thing that "git clone" and other utils do.
$self->run_git(
[ config => 'branch.master.rebase', 'true' ]
) if $self->setup_rebase;
}
1;
__END__
=pod
=head1 NAME
Github::Import - Import your project into L<http://github.com>
=head1 SYNOPSIS
# You can see your token at https://github.com/account
% cd some_project_in_git
% github-import --username jrockway --token decafbad --add-remote --push-mode all
You can also create a config file. Here is an example using a real man's editor:
% git config --add github.user jrockway
% git config --add github.token 91ceb00b1es
% git config --add github-import.remote origin # if you don't like "github"
% cd some_other_project_in_git
% github-import
=head1 DESCRIPTION
This class/script provides a way to import a git repository into
L<http://github.com>.
=head1 CONFIGURATION
The standard git configuration file is used to obtain values for the attributes
listed below.
If no value is specified in the config file, the default one in the
documentation will be used.
For instance to not push to github, set:
[github-import]
push: false
( run in 1.013 second using v1.01-cache-2.11-cpan-d7f47b0818f )