Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move duplicated code from Configure.pl and CompareRevisions.pm
  • Loading branch information
fernandobrito committed Dec 2, 2010
1 parent bba62f3 commit bf97c8f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
7 changes: 2 additions & 5 deletions Configure.pl
Expand Up @@ -7,7 +7,7 @@
use Getopt::Long;
use Cwd;
use lib "build/lib";
use Parrot::CompareRevisions qw(compare_parrot_revs);
use Parrot::CompareRevisions qw(compare_parrot_revs parse_parrot_revision_file);

MAIN: {
my %options;
Expand All @@ -21,10 +21,7 @@
}

# Determine the revision of Parrot we require
open my $REQ, '<', "build/PARROT_REVISION"
or die "cannot open build/PARROT_REVISION: $!\n";
my ($reqsvn, $reqpar) = split(' ', <$REQ>);
close $REQ;
my ($reqsvn, $reqpar) = parse_parrot_revision_file;

# Update/generate parrot build if needed
if ($options{'gen-parrot'}) {
Expand Down
9 changes: 3 additions & 6 deletions build/gen_parrot.pl
Expand Up @@ -22,16 +22,13 @@ =head2 DESCRIPTION
use 5.008;

use lib "build/lib";
use Parrot::CompareRevisions qw(compare_parrot_revs);
use Parrot::CompareRevisions qw(compare_parrot_revs parse_parrot_revision_file);

# Work out slash character to use.
my $slash = $^O eq 'MSWin32' ? '\\' : '/';

## determine what revision of Parrot we require
open my $REQ, "build/PARROT_REVISION"
|| die "cannot open build/PARROT_REVISION\n";
my ($req, $reqpar) = split(' ', <$REQ>);
close $REQ;
# Determine the revision of Parrot we require
my ($req, $reqpar) = parse_parrot_revision_file;

{
no warnings;
Expand Down
12 changes: 11 additions & 1 deletion build/lib/Parrot/CompareRevisions.pm
Expand Up @@ -3,7 +3,17 @@ use strict;
use warnings;

use base qw(Exporter);
our @EXPORT_OK = qw(compare_parrot_revs parse_parrot_git_describe);
our @EXPORT_OK = qw(compare_parrot_revs parse_parrot_git_describe parse_parrot_revision_file);

sub parse_parrot_revision_file {
# Open the build/PARROT_REVISION file
open my $REQ, '<', "build/PARROT_REVISION"
or die "cannot open build/PARROT_REVISION: $!\n";
my ($req, $reqpar) = split(' ', <$REQ>);
close $REQ;

return $req, $reqpar
}

sub parse_parrot_git_describe {
my $g = shift;
Expand Down

0 comments on commit bf97c8f

Please sign in to comment.