}
sub _extract {
- my ($self, $target) = @_;
+ my ($self, $target, $since) = @_;
my $git = $self->{git};
# read all of the state file
my $new; # arrayref of new file pathnames in a git tree
+ if (defined $since) {
+ my @cmd = (qw(git rev-list), "--since=$since", $tip);
+ my $tmp;
+
+ # get the commit last in the list, unfortunately --reverse
+ # is not usable with --since
+ open my $rl, '-|', @cmd or die "failed to open rev-list: $!\n";
+ foreach my $cmt (<$rl>) {
+ chomp $cmt;
+
+ # do not re-import even if --since is specified
+ if (defined $last && ($last eq $cmt)) {
+ $tmp = undef;
+ last
+ }
+ $tmp = $cmt;
+ }
+ close $rl; # we may break the pipe here
+ $last = $tmp if defined $tmp;
+ }
if (defined $last) {
# only inject newly-added
$last =~ /\A[a-f0-9]{40}\z/ or die "$lkey invalid in $state\n";
}
sub extract {
- my ($self, $target) = @_;
- $self->{git}->tmp_git_do(sub { $self->_extract($target) });
+ my ($self, $target, $since) = @_;
+ $self->{git}->tmp_git_do(sub { $self->_extract($target, $since) });
}
sub _deliver_die {
"sync" => {
doc => "sync target(s) for existing LISTNAME",
arg => "[LISTNAME] [TARGET]",
- opt => { "cron" => \$opts{cron} }
+ opt => {
+ cron => \$opts{cron},
+ 'since=s' => \$opts{since},
+ 'after=s' => \$opts{since},
+ }
},
"cat" => {
doc => "show a message by Message-ID",
my ($dir, $targets) = @_;
my $git = Ssoma::Git->new($dir);
my $ex = Ssoma::Extractor->new($git);
+ my $since = $opts{since};
# no targets? sync all of them
if (scalar(@$targets) == 0) {
});
foreach my $target (@$targets) {
- $ex->extract($target);
+ $ex->extract($target, $since);
}
}