Skip to content

Commit bdc690e

Browse files
committed
Skip git manipulation if GITROOT is empty
Keeping track of the changes done on the production environment is nice, but it is useless while developing or testing on a local environment. It would be nice if we could skip git manipulation by setting GITROOT to empty, or by any other mean.
1 parent cc2433a commit bdc690e

File tree

1 file changed

+36
-28
lines changed

1 file changed

+36
-28
lines changed

lib/PAUSE/mldistwatch.pm

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ sub permissions {
161161
sub rewrite_indexes {
162162
my $self = shift;
163163

164-
$self->git->reset({ hard => 1 })
165-
if -e dir($self->gitroot)->file(qw(.git refs heads master));
164+
if ($PAUSE::Config->{GITROOT}) {
165+
$self->git->reset({ hard => 1 })
166+
if -e dir($self->gitroot)->file(qw(.git refs heads master));
167+
}
166168

167169
$self->rewrite02();
168170
my $MLROOT = $self->mlroot;
@@ -173,8 +175,10 @@ sub rewrite_indexes {
173175
$self->rewrite06();
174176
$Logger->log("finished rewriting indexes");
175177

176-
$self->git->commit({ m => "indexer run at $^T, pid $$" })
177-
if $self->git->status->is_dirty;
178+
if ($PAUSE::Config->{GITROOT}) {
179+
$self->git->commit({ m => "indexer run at $^T, pid $$" })
180+
if $self->git->status->is_dirty;
181+
}
178182
}
179183
180184
sub debug_mem {
@@ -711,21 +715,23 @@ Last-Updated: $date\n\n};
711715

712716
$list .= join "", sort {lc $a cmp lc $b} @listing02;
713717
if ($list ne $olist) {
714-
my $F;
715-
my $gitfile = File::Spec->catfile(
716-
$self->gitroot,
717-
'02packages.details.txt',
718-
);
719-
if (open $F, ">", $gitfile) {
720-
print $F $header;
721-
print $F $list;
722-
} else {
723-
$Logger->log("couldn't open $repfile for writing 02packages: $!");
724-
}
725-
close $F or die "Couldn't close: $!";
726-
$self->git->add({}, '02packages.details.txt');
718+
if ($PAUSE::Config->{GITROOT}) {
719+
my $F;
720+
my $gitfile = File::Spec->catfile(
721+
$self->gitroot,
722+
'02packages.details.txt',
723+
);
724+
if (open $F, ">", $gitfile) {
725+
print $F $header;
726+
print $F $list;
727+
} else {
728+
$Logger->log("couldn't open $repfile for writing 02packages: $!");
729+
}
730+
close $F or die "Couldn't close: $!";
731+
$self->git->add({}, '02packages.details.txt');
727732

728-
$self->_install($gitfile);
733+
$self->_install($gitfile);
734+
}
729735

730736
PAUSE::newfile_hook($repfile);
731737
0==system "$GZIP $PAUSE::Config->{GZIP_OPTIONS} --stdout $repfile > $repfile.gz.new"
@@ -1321,17 +1327,19 @@ Date: %s
13211327
if ($list eq $olist) {
13221328
$Logger->log("06perms.txt has not changed; won't rewrite");
13231329
} else {
1324-
my $F;
1325-
my $gitfile = File::Spec->catfile($self->gitroot, '06perms.txt');
1326-
if (open $F, ">:utf8", $gitfile) {
1327-
print $F $header;
1328-
print $F $list;
1329-
} else {
1330-
$Logger->log("couldn't open $gitfile: $!");
1330+
if ($PAUSE::Config->{GITROOT}) {
1331+
my $F;
1332+
my $gitfile = File::Spec->catfile($self->gitroot, '06perms.txt');
1333+
if (open $F, ">:utf8", $gitfile) {
1334+
print $F $header;
1335+
print $F $list;
1336+
} else {
1337+
$Logger->log("couldn't open $gitfile: $!");
1338+
}
1339+
close $F or die "Couldn't close: $!";
1340+
$self->git->add({}, '06perms.txt');
1341+
$self->_install($gitfile);
13311342
}
1332-
close $F or die "Couldn't close: $!";
1333-
$self->git->add({}, '06perms.txt');
1334-
$self->_install($gitfile);
13351343
PAUSE::newfile_hook($repfile);
13361344
0==system "$GZIP $PAUSE::Config->{GZIP_OPTIONS} --stdout $repfile > $repfile.gz.new"
13371345
or $Logger->log([ "couldn't gzip $repfile: %s", Process::Status->as_struct ]);

0 commit comments

Comments
 (0)