|
1 | 1 | #!perl
|
2 | 2 |
|
| 3 | +use strict; |
| 4 | +use warnings; |
| 5 | + |
3 | 6 | use 5.010;
|
4 | 7 |
|
5 |
| -use File::Copy qw( copy ); |
| 8 | +use Cwd qw( cwd ); |
| 9 | +use File::Copy qw( copy ); |
6 | 10 | use File::Spec::Functions;
|
7 | 11 |
|
8 | 12 | my $cpanpm_base = $ARGV[0] || '../cpanpm';
|
9 |
| -die "Couldn't find cpanpm repository at $cpanpm_base\n"; |
| 13 | +die "Couldn't find cpanpm repository at $cpanpm_base\n" |
| 14 | + unless -d $cpanpm_base; |
10 | 15 |
|
11 | 16 | {
|
12 |
| -my $cwd = Cwd(); |
| 17 | +my $cwd = cwd(); |
13 | 18 | chdir $cpanpm_base or die "Couldn't chdir to $cpanpm_base";
|
14 | 19 |
|
15 |
| -my $branch = grep { /^\*\s*(.*)/ } `git branch`; |
16 |
| -die "Branch is not 'update_cpan'\n" unless $branch eq 'update_cpan'; |
| 20 | +my( $branch ) = map { /^\*\s*(.*)/ ? $1 : () } `git branch`; |
| 21 | + |
| 22 | +#die "Branch is not 'update_cpan'\n" unless $branch eq 'update_cpan'; |
| 23 | +print "branch is [$branch]\n"; |
17 | 24 |
|
18 | 25 | my $uptodate = ( `git pull` =~ /Already/ );
|
19 | 26 | die "Repo is not up to date! Stopping!\n" unless $uptodate;
|
20 | 27 |
|
21 | 28 | chdir $cwd or die "Couldn't chdir back to $cwd";
|
22 | 29 | }
|
23 | 30 |
|
24 |
| -my @file_to_copy = ( |
| 31 | +my @files_to_copy = ( |
25 | 32 | [ qw( lib/Cpan.pm lib/App/Cpan.pm ) ],
|
26 | 33 | [ qw( script/cpan scripts/cpan ) ],
|
27 | 34 | );
|
28 | 35 |
|
29 | 36 | foreach my $pair ( @files_to_copy ) {
|
30 | 37 | my( $original, $copy_rel, $mode ) = @$pair;
|
31 |
| - |
32 | 38 | warn "Could not find $original\n" unless -e $original;
|
33 | 39 | my $destination = catfile( $cpanpm_base, $copy_rel );
|
| 40 | + print "Copying $original -> $destination\n"; |
34 | 41 | copy( $original, $destination ) or warn "Copy failed: $!";
|
35 | 42 | }
|
0 commit comments