1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!perl
#
# 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 strict;
use warnings;
use Dist::Zilla 1.093250;
use Dist::Zilla::Tester;
use File::Temp qw{ tempdir };
use Git::Wrapper;
use Path::Class;
use File::Copy 'move';
use Test::More tests => 1;
# Mock HOME to avoid ~/.gitexcludes from causing problems
$ENV{HOME} = tempdir( CLEANUP => 1 );
# build fake repository
my $zilla = Dist::Zilla::Tester->from_config({
dist_root => dir('corpus/repo-dir')->absolute,
});
chdir $zilla->tempdir->subdir( 'source' );
system "git init";
my $git = Git::Wrapper->new('.');
$git->config( 'user.name' => 'dzp-git test' );
$git->config( 'user.email' => 'dzp-git@test' );
mkdir 'dist';
# move corpus files to subdir of git repo
move 'dist.ini', 'dist/dist.ini';
move 'Changes', 'dist/Changes';
# do a release in a subdir; the git repo is one level up
chdir 'dist';
$git->add( qw{ dist.ini Changes } );
$git->commit( { message => 'initial commit' } );
append_to_file('Changes', "\n");
append_to_file('dist.ini', "\n");
# create a new zilla with dist root in the right place
my $zilla2 = Dist::Zilla::Dist::Builder->from_config( { chrome => Dist::Zilla::Chrome::Test->new } );
$zilla2->release;
# check if dist.ini and changelog have been committed
my ($log) = $git->log( 'HEAD' );
like( $log->message, qr/v1.23\n[^a-z]*foo[^a-z]*bar[^a-z]*baz/, 'commit message taken from changelog' );
sub append_to_file {
my ($file, @lines) = @_;
open my $fh, '>>', $file or die "can't open $file: $!";
print $fh @lines;
close $fh;
}
|