Since public-inbox-clone is now useful for incremental updates
with manifest, --exit-code belongs here, too.
Pass the C<--prune> and C<--prune-tags> flags to L<git-fetch(1)>
calls on incremental clones.
Pass the C<--prune> and C<--prune-tags> flags to L<git-fetch(1)>
calls on incremental clones.
+=item --exit-code
+
+Exit with C<127> if no updates are done when relying on a manifest.
+Updates include fingerprint mismatches in the manifest, new symlinks,
+new repositories, and removed repositories from the L<--project-list>
+
=item -k
=item --keep-going
=item -k
=item --keep-going
fetch_args($self->{lei}, $opt), $rn ];
push @$cmd, '-P' if $self->{lei}->{prune}; # --prune-tags implied
my $run_puh = PublicInbox::OnDestroy->new($$, \&run_puh, $self, $fini);
fetch_args($self->{lei}, $opt), $rn ];
push @$cmd, '-P' if $self->{lei}->{prune}; # --prune-tags implied
my $run_puh = PublicInbox::OnDestroy->new($$, \&run_puh, $self, $fini);
+ ++$self->{chg}->{nr_chg};
start_cmd($self, $cmd, $opt, $run_puh);
}
start_cmd($self, $cmd, $opt, $run_puh);
}
$fgrp->{dry_run} ? $fgrp->{lei}->qerr("# @cmd @kv") :
run_die([@cmd, @kv], undef, $opt);
}
$fgrp->{dry_run} ? $fgrp->{lei}->qerr("# @cmd @kv") :
run_die([@cmd, @kv], undef, $opt);
}
+ ++$fgrp->{chg}->{nr_chg};
push @{$FGRP_TODO->{$fgrp->{-osdir}}}, $fgrp;
}
push @{$FGRP_TODO->{$fgrp->{-osdir}}}, $fgrp;
}
+ ++$self->{chg}->{nr_chg};
start_cmd($self, $cmd, $opt, PublicInbox::OnDestroy->new($$,
\&run_puh, $self, $fini));
}
start_cmd($self, $cmd, $opt, PublicInbox::OnDestroy->new($$,
\&run_puh, $self, $fini));
}
}
}
symlink($tgt, $ln) or die "symlink($tgt, $ln): $!";
}
}
symlink($tgt, $ln) or die "symlink($tgt, $ln): $!";
+ ++$self->{chg}->{nr_chg};
}
}
if (defined(my $t = $self->{-ent}->{modified})) {
}
}
if (defined(my $t = $self->{-ent}->{modified})) {
warn "\t", $_, "\n" for @local;
my (undef, $dn, $bn) = File::Spec->splitpath($f);
warn "\t", $_, "\n" for @local;
my (undef, $dn, $bn) = File::Spec->splitpath($f);
+ $self->{chg}->{nr_chg} += scalar(@remote) + scalar(@local);
atomic_write($dn, $bn, join("\n", @list, ''));
}
atomic_write($dn, $bn, join("\n", @list, ''));
}
}
# bail out if curl -z/--timecond hit 304 Not Modified, $ft will be empty
}
# bail out if curl -z/--timecond hit 304 Not Modified, $ft will be empty
- return $lei->qerr("# $manifest unchanged") if -f $manifest && !-s $ft;
+ if (-f $manifest && !-s $ft) {
+ $lei->child_error(127 << 8) if $lei->{opt}->{'exit-code'};
+ return $lei->qerr("# $manifest unchanged");
+ }
my $m = eval { decode_manifest($ft, $ft, $uri) };
if ($@) {
my $m = eval { decode_manifest($ft, $ft, $uri) };
if ($@) {
EOM
dump_project_list($self, $m);
ft_rename($ft, $manifest, 0666);
EOM
dump_project_list($self, $m);
ft_rename($ft, $manifest, 0666);
+ !$self->{chg}->{nr_chg} && $lei->{opt}->{'exit-code'} and
+ $lei->child_error(127 << 8);
GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@
inbox-config=s inbox-version=i objstore=s manifest=s
project-list|projectslist=s post-update-hook=s@
GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@
inbox-config=s inbox-version=i objstore=s manifest=s
project-list|projectslist=s post-update-hook=s@
+ prune|p keep-going|k exit-code
dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help;
if ($opt->{help}) { print $help; exit };
require PublicInbox::Admin; # loads Config
dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help;
if ($opt->{help}) { print $help; exit };
require PublicInbox::Admin; # loads Config
}
my $cmd = [qw(-clone --inbox-config=never --manifest= --project-list=
}
my $cmd = [qw(-clone --inbox-config=never --manifest= --project-list=
- --objstore= -p -q), $url, "$tmpdir/dst"];
+ --objstore= -p -q), $url, "$tmpdir/dst", '--exit-code'];
ok(run_script($cmd), 'clone');
is(xqx([qw(git config gitweb.owner)], { GIT_DIR => "$tmpdir/dst/a.git" }),
"Alice\n", 'a.git gitweb.owner set');
ok(run_script($cmd), 'clone');
is(xqx([qw(git config gitweb.owner)], { GIT_DIR => "$tmpdir/dst/a.git" }),
"Alice\n", 'a.git gitweb.owner set');
unlink($log) or xbail "unlink: $!";
ok(run_script($x, $env), "no-op clone @clone_arg w/ post-update-hook");
ok(!-e $log, "hooks not run on no-op @clone_arg");
unlink($log) or xbail "unlink: $!";
ok(run_script($x, $env), "no-op clone @clone_arg w/ post-update-hook");
ok(!-e $log, "hooks not run on no-op @clone_arg");
+
+ push @$x, '--exit-code';
+ ok(!run_script($x, $env), 'no-op clone w/ --exit-code fails');
+ is($? >> 8, 127, '--exit-code gave 127');
};
$test_puh->();
ok(!-e "$tmpdir/dst/objstore", 'no objstore, yet');
};
$test_puh->();
ok(!-e "$tmpdir/dst/objstore", 'no objstore, yet');