+# lots of this stuff was sponsored by socialflow.com
+
package File::Tree::Snapshot;
use Moo;
use File::Path;
sub _has_changes {
my ($self) = @_;
my $path = $self->storage_path;
- my @changes = `cd $path && git diff --name-only --cached`;
+ my $cmd = qq{cd $path && git diff --name-only --cached};
+ CORE::open my $handle, '-|', $cmd
+ or die "Unable to find changes in ($cmd): $!\n";
+ my @changes = <$handle>;
return scalar @changes;
}
sub reset {
my ($self) = @_;
$self->_git_exec('add .');
+ return 1
+ unless $self->_has_changes;
$self->_git_exec('checkout -f');
return 1;
}
Rolls back the changes since the last snapshot.
+=head1 SPONSORED
+
+The development of this module was sponsored by L<http://socialflow.com/>.
+
=cut