The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Git::Database::Role::Backend - Abstract role for a Git database backend

VERSION

version 0.002

SYNOPSIS

    package MyGitBackend;

    use Moo;
    use namespace::clean;

    with 'Git::Database::Role::Backend';

    1;

DESCRIPTION

The Git::Database::Role::Backend role encapsulate code for the user-facing store objects. To be usable as a backend, a class must at least do this role.

REQUIRED ATTRIBUTES

store

The store that will store and retrieve data from the Git repository.

There is a has_store predicate method for this attribute.

METHODS

hash_object

    # the empty tree
    my $tree = Git::Database::Object::Tree->new( content => '' );
    
    # 4b825dc642cb6eb9a060e54bf8d69288fbee4904
    my $digest = $backend->hash_object( $tree );

Compute and return the SHA-1 digest for the given object.

May be called from the digest builder for one of the object classes (Git::Database::Object::Blob, Git::Database::Object::Tree, Git::Database::Object::Commit, Git::Database::Object::Tag), so the implementation should not try to shortcut and call $object->digest.

The role provides a Perl implementation for it, but most backends will want to override it for performance reasons.

AUTHOR

Philippe Bruhat (BooK) <book@cpan.org>

COPYRIGHT

Copyright 2016 Philippe Bruhat (BooK), all rights reserved.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.