Git::Database::Role::Backend - Abstract role for a Git database backend
package MyGitBackend; use Moo; use namespace::clean; with 'Git::Database::Role::Backend'; 1;
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.
The store that will store and retrieve data from the Git repository.
There is a
has_store predicate method for this attribute.
# 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
The role provides a Perl implementation for it, but most backends will want to override it for performance reasons.
# argument is a HASH reference my $object = $store->create_object( \%attr ); # arguments is a list of pairs my $object = $store->create_object( %attr );
Return an object instance of an object doing the Git::Database::Role::Object role, or
kind is unknown or not provided.
This method assumes the provided attribute values are consistent for the object kind. Behaviour is undefined if the various attributes are not internally consistent. (E.g. if the size does not match the content.)
Note: this method creates new objects, but does not store them in the underlying Git datatase. Do save them in the database, use "put_object" in Git::Database::Role::Object::Writer.
Philippe Bruhat (BooK) <firstname.lastname@example.org>
Copyright 2016 Philippe Bruhat (BooK), all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.