File: commit-utf8.t

package info (click to toggle)
libdist-zilla-plugin-git-perl 2.051-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 712 kB
  • sloc: perl: 1,306; makefile: 11
file content (63 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;
use utf8;

use Dist::Zilla  1.093250;
use Dist::Zilla::Tester;
use Encode qw( decode );
use File::pushd qw(pushd);
use Path::Tiny 0.012 qw(path); # cwd
use Test::More;

plan skip_all => "Dist::Zilla 5 required" if Dist::Zilla->VERSION < 5;
plan tests => 1;

use lib 't/lib';
use Util qw(clean_environment init_repo);

# Mock HOME to avoid ~/.gitexcludes from causing problems
# and clear GIT_ environment variables
my $homedir = clean_environment;

# UTF-8 encoded strings:
my $changes1 = 'Ævar Arnfjörð Bjarmason';
my $changes2 = 'ブログの情報';
my $changes3 = 'plain ASCII';

# build fake repository
my $zilla = Dist::Zilla::Tester->from_config({
  dist_root => path('corpus/commit')->absolute,
},{
  add_files => {
    'source/Changes' => <<"END CHANGES",
Changes

1.23 2012-11-10 19:15:45 CET
 - $changes1
 - $changes2
 - $changes3
END CHANGES
  },
});

{
  my $dir = pushd(path($zilla->tempdir)->child('source'));

  my $git = init_repo( qw{ .  dist.ini Changes } );

  # do a release, with changes and dist.ini updated
  append_to_file('Changes',  "\n");
  append_to_file('dist.ini', "\n");
  $zilla->release;

  # check if dist.ini and changelog have been committed
  my ($log) = $git->log( 'HEAD' );
  like( decode('UTF-8', $log->message), qr/v1.23\n[^a-z]*\Q$changes1\E[^a-z]*\Q$changes2\E[^a-z]*\Q$changes3\E/, 'commit message taken from changelog' );
}

sub append_to_file {
    my ($file, @lines) = @_;
    my $fh = path($file)->opena;
    print $fh @lines;
    close $fh;
}