allow AUTHOR to be overridden
[p5sagit/Distar.git] / lib / Distar.pm
index a0d126c..5cf0c1e 100644 (file)
@@ -1,6 +1,7 @@
 package Distar;
 
-use strictures 1;
+use strict;
+use warnings FATAL => 'all';
 use base qw(Exporter);
 use ExtUtils::MakeMaker ();
 use ExtUtils::MM ();
@@ -11,16 +12,23 @@ use File::Spec;
 our $VERSION = '0.001000';
 $VERSION = eval $VERSION;
 
+my $MM_VER = eval $ExtUtils::MakeMaker::VERSION;
+
 our @EXPORT = qw(
   author manifest_include run_preflight
 );
 
 sub import {
-  strictures->import;
+  strict->import;
+  warnings->import(FATAL => 'all');
   shift->export_to_level(1,@_);
 }
 
-sub author { our $Author = shift }
+sub author {
+  our $Author = shift;
+  $Author = [ $Author ]
+    if !ref $Author;
+}
 
 our $Ran_Preflight;
 
@@ -63,11 +71,14 @@ sub run_preflight {
   $Ran_Preflight = 1;
   my $version = $ARGV[0];
 
-  system("git fetch");
-
   my $make = $Config{make};
   my $null = File::Spec->devnull;
 
+  system("git fetch");
+  if (system("git rev-parse --quiet --verify v$version >$null") == 0) {
+    die "Tag v$version already exists!";
+  }
+
   require File::Find;
   File::Find::find({ no_chdir => 1, wanted => sub {
     return
@@ -82,7 +93,7 @@ sub run_preflight {
   }
 
   for (scalar `git status`) {
-    /^# On branch master/ || die "Not on master. EEEK";
+    /^(?:# )?On branch master/ || die "Not on master. EEEK";
     /Your branch is behind|Your branch and .*? have diverged/ && die "Not synced with upstream";
   }
 
@@ -90,14 +101,17 @@ sub run_preflight {
     length && die "Outstanding changes";
   }
   my $ymd = sprintf(
-    "%i-%02i-%02i", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3]
+    "%i-%02i-%02i", (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3]
   );
-  my $changes_line = "$version   $ymd\n";
+  my $changes_line = "$version - $ymd\n";
   my @cached = grep /^\+/, `git diff --cached -U0`;
   @cached > 0 or die "Please add:\n\n$changes_line\nto Changes stage Changes (git add Changes)";
   @cached == 2 or die "Pre-commit Changes not just Changes line";
   $cached[0] =~ /^\+\+\+ .\/Changes\n/ or die "Changes not changed";
   $cached[1] eq "+$changes_line" or die "Changes new line should be: \n\n$changes_line ";
+
+  { no warnings 'exec'; `cpan-upload -h`; }
+  $? and die "cpan-upload not available";
 }
 
 {
@@ -108,11 +122,12 @@ sub run_preflight {
   sub new {
     my ($class, $args) = @_;
     return $class->SUPER::new({
-      LICENSE => 'perl',
+      LICENSE => 'perl_5',
+      MIN_PERL_VERSION => '5.006',
+      AUTHOR => ($MM_VER >= 6.5702 ? $Distar::Author : $Distar::Author->[0]),
       %$args,
-      AUTHOR => $Distar::Author,
       ABSTRACT_FROM => $args->{VERSION_FROM},
-      test => { TESTS => ($args->{test}{TESTS}||'t/*.t').' xt/*.t' },
+      test => { TESTS => ($args->{test}{TESTS}||'t/*.t').' xt/*.t xt/*/*.t' },
     });
   }
 
@@ -135,6 +150,9 @@ distdir: readmefile
 readmefile: create_distdir
        pod2text $(VERSION_FROM) >$(DISTVNAME)/README
        $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
+disttest: distmanicheck
+distmanicheck: create_distdir
+       cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"
 
 END
     if (open my $fh, '<', 'maint/Makefile.include') {