From 5bf3eb1d89736c97e1cd2289a6d7c57da718f502 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Mon, 19 Dec 2016 21:33:02 -0700 Subject: [PATCH] Add autogeneration_warning option This options (on by default) adds a comment at the top of the .travis.yml file to indicate to would-be contributors that the file is autogenerated and should therefore not be directly edited. --- lib/Dist/Zilla/Role/TravisYML.pm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/Dist/Zilla/Role/TravisYML.pm b/lib/Dist/Zilla/Role/TravisYML.pm index 2767a60..7ddefa9 100644 --- a/lib/Dist/Zilla/Role/TravisYML.pm +++ b/lib/Dist/Zilla/Role/TravisYML.pm @@ -56,15 +56,16 @@ has $_ => ( rw, isa => ArrayRef[Str], default => sub { [] } ) for ( @phases ); -has dzil_branch => ( rw, isa => Str ); -has build_branch => ( rw, isa => Str, default => '/^build\/.*/' ); -has notify_email => ( rw, isa => ArrayRef[Str], default => sub { [ 1 ] } ); -has notify_irc => ( rw, isa => ArrayRef[Str], default => sub { [ 0 ] } ); -has mvdt => ( rw, isa => Bool, default => 0 ); -has test_authordeps => ( rw, isa => Bool, default => 0 ); -has test_deps => ( rw, isa => Bool, default => 1 ); -has support_builddir => ( rw, isa => Bool, default => 0 ); -has sudo => ( rw, isa => Bool, default => 0 ); +has dzil_branch => ( rw, isa => Str ); +has build_branch => ( rw, isa => Str, default => '/^build\/.*/' ); +has notify_email => ( rw, isa => ArrayRef[Str], default => sub { [ 1 ] } ); +has notify_irc => ( rw, isa => ArrayRef[Str], default => sub { [ 0 ] } ); +has mvdt => ( rw, isa => Bool, default => 0 ); +has test_authordeps => ( rw, isa => Bool, default => 0 ); +has test_deps => ( rw, isa => Bool, default => 1 ); +has support_builddir => ( rw, isa => Bool, default => 0 ); +has sudo => ( rw, isa => Bool, default => 0 ); +has autogeneration_warning => ( rw, isa => Bool, default => 1 ); has irc_template => ( rw, isa => ArrayRef[Str], default => sub { [ "%{branch}#%{build_number} by %{author}: %{message} (%{build_url})", @@ -352,6 +353,10 @@ sub build_travis_yml { $travis_yml =~ s/^(\s+- )(5\.\d+|blead)$/$1'$2'/gm; $travis_yml =~ s/^(\s+(?:- )?perl: )(5\.\d+|blead)$/$1'$2'/gm; + if ($self->autogeneration_warning) { + $travis_yml = "# Autogenerated from dist.ini by ".__PACKAGE__." - DO NOT EDIT!\n$travis_yml"; + } + my $file = Path::Class::File->new($self->zilla->built_in, '.travis.yml'); $file->spew($travis_yml); return $file;