NAME
Git::Annex - Perl interface to git-annex repositories
VERSION
version 0.008
SYNOPSIS
my $annex = Git::Annex->new("/home/spwhitton/annex");
# run `git annex unused` and then `git log` to get information about
# unused git annex keys
my $unused_files
= $self->unused(used_refspec => "+refs/heads/master", log => 1);
for my $unused_file (@$unused_files) {
say "unused file " . $unused_file->{key} . ":";
say "";
say " $_" for $unused_file->{log_lines};
say "";
say "you can drop it with: `git annex dropunused "
. $unused_file->{number} . "`";
say "";
}
# embedded Git::Wrapper instance with shortcut to access annex subcommands
say for $annex->annex->find(qw(--not --in here));
$annex->annex->copy(qw(-t cloud --in here --and --lackingcopies=1));
DESCRIPTION
An instance of the Git::Annex class represents a git repository in which git annex init has been run. This module provides some useful methods for working with such repositories from Perl. See https://git-annex.branchable.com/ for more information on git-annex.
ATTRIBUTES
toplevel
The root of the repository.
git
An instance of Git::Wrapper initialised in the repository.
annex
Gives access to git-annex subcommands in the same way that Git::Annex::git gives access to git subcommands. So
$self->git->annex("contentlocation", $key);
may be written
$self->annex->contentlocation($key);
METHODS
new($dir)
Instantiate an object representing a git-annex located in $dir.
unused(%opts)
Runs git annex unused and returns a hashref containing information on unused files.
The information is cached inside the .git/annex directory. This means that a user can keep running your script without repeatedly executing expensive git annex and git log commands.
Optional arguments:
- log
-
If true, run
git log --stat -Son each unused file, to see what filenames the unused data had if and when it was used data in the annex.Defaults to false, but if there is log data in the cache it will always be returned.
- from
-
Corresponds to the
--fromoption togit annex unused. - used_refspec
-
Corresponds to the
--used-refspecoption togit annex unused.Defaults to the
annex.used-refspecgit config key if set, or+refs/heads/*:-refs/heads/synced/*.
abs_contentlocation($key)
Returns an absolute path to the content for git-annex key $key.
batch($cmd, @args)
Instantiate a Git::Annex::BatchCommand object by starting up a git-annex --batch command.
my $batch = $annex->batch("find", "--in=here");
say "foo/bar annexed content is present in this repo"
if $batch->say("foo/bar");
# kill the batch process:
undef $batch;
AUTHOR
Sean Whitton <spwhitton@spwhitton.name>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2019-2021 by Sean Whitton <spwhitton@spwhitton.name>.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007