summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-02-01 12:07:44 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-02-01 12:07:44 -0700
commit7c6d991939009024e233d345d3e165017ff17e41 (patch)
tree774b15cc8df482e5adf409ee273496580a614540 /lib
parent8a8a668b3ad3c47a0e761b9fa6dab580e7dba32e (diff)
downloadp5-Git-Annex-7c6d991939009024e233d345d3e165017ff17e41.tar.gz
add .git dir utils
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'lib')
-rw-r--r--lib/Git/Annex.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Git/Annex.pm b/lib/Git/Annex.pm
index 1cd26f4..7d923f9 100644
--- a/lib/Git/Annex.pm
+++ b/lib/Git/Annex.pm
@@ -66,6 +66,7 @@ use Cwd;
use File::chdir;
use Git::Wrapper;
use Git::Repository;
+use File::Spec::Functions qw(catfile rel2abs);
use Moo;
use namespace::clean;
@@ -103,6 +104,22 @@ has repo => (
# Git::Repository::new, so we chdir and let call without arguments
default => sub { local $CWD = shift->toplevel; Git::Repository->new });
+has _unused_cache => (
+ is => "lazy",
+ default => sub { shift->_git_path(catfile(qw(annex unused_info))) });
+
+sub _clear_unused_cache {
+ my $self = shift;
+ delete $self->{_unused};
+ unlink $self->_unused_cache;
+}
+
+sub _git_path {
+ my ($self, $input) = @_;
+ my ($path) = $self->git->rev_parse({ git_path => 1 }, $input);
+ rel2abs($path, $self->toplevel);
+}
+
around BUILDARGS => sub {
my (undef, undef, @args) = @_;
{ toplevel => $args[0] // getcwd };