| Dist-Zilla-Plugin-Git documentation | Contained in the Dist-Zilla-Plugin-Git distribution. |
initial commit.OPTION VALUE. This may be specified multiple times to add multiple entries.NAME URL. This may be
specified multiple times to add multiple remotes.
Dist::Zilla::Plugin::Git::Init - initialize git repository on dzil new
version 1.111590
In your profile.ini:
[Git::Init]
commit_message = initial commit ; this is the default
remote = origin git@github.com:USERNAME/%{lc}N.git ; no default
config = user.email USERID@cpan.org ; there is no default
This plugin initializes a git repository when a new distribution is
created with dzil new.
The plugin accepts the following options:
initial commit.OPTION VALUE. This may be specified multiple times to add multiple entries.NAME URL. This may be
specified multiple times to add multiple remotes.You can use the following codes in commit_message, config, or remote:
%nA newline.
%NThe distribution name. You can also use %{lc}N or %{uc}N to get
the name in lower case or upper case, respectively.
Jerome Quelin
This software is copyright (c) 2009 by Jerome Quelin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| Dist-Zilla-Plugin-Git documentation | Contained in the Dist-Zilla-Plugin-Git distribution. |
# # This file is part of Dist-Zilla-Plugin-Git # # This software is copyright (c) 2009 by Jerome Quelin. # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use 5.010; use strict; use warnings; package Dist::Zilla::Plugin::Git::Init; BEGIN { $Dist::Zilla::Plugin::Git::Init::VERSION = '1.111590'; } # ABSTRACT: initialize git repository on dzil new our %transform = ( lc => sub { lc shift }, uc => sub { uc shift }, '' => sub { shift }, ); use Moose; use Git::Wrapper; use String::Formatter method_stringf => { -as => '_format_string', codes => { n => sub { "\n" }, N => sub { $transform{$_[1] || ''}->( $_[0]->zilla->name ) }, }, }; with 'Dist::Zilla::Role::AfterMint'; has commit_message => ( is => 'ro', isa => 'Str', default => 'initial commit', ); has remotes => ( is => 'ro', isa => 'ArrayRef[Str]', default => sub { [] }, ); has config_entries => ( is => 'ro', isa => 'ArrayRef[Str]', default => sub { [] }, ); sub mvp_multivalue_args { qw(config_entries remotes) } sub mvp_aliases { return { config => 'config_entries', remote => 'remotes' } } sub after_mint { my $self = shift; my ($opts) = @_; my $git = Git::Wrapper->new($opts->{mint_root}); $self->log("Initializing a new git repository in " . $opts->{mint_root}); $git->init; foreach my $configSpec (@{ $self->config_entries }) { my ($option, $value) = split ' ', _format_string($configSpec, $self), 2; $self->log_debug("Configuring $option $value"); $git->config($option, $value); } $git->add($opts->{mint_root}); $git->commit({message => _format_string($self->commit_message, $self)}); foreach my $remoteSpec (@{ $self->remotes }) { my ($remote, $url) = split ' ', _format_string($remoteSpec, $self), 2; $self->log_debug("Adding remote $remote as $url"); $git->remote(add => $remote, $url); } } 1;
__END__