Yukki::Model::Repository - model for accessing objects in a git repository


version 0.140290


  my $repository = $app->model('Repository', { name => 'main' });
  my $file = $repository->file({ path => 'foo.yukki' });


This model contains methods for performing all the individual operations required to store files into and fetch files from the git repository. It includes tools for building trees, commiting, creating blobs, fetching file lists, etc.





This is the name of the repository. This is used to lookup the configuration for the repository from the yukki.conf.


These are the settings telling this model where to find the git repository and how to access it. It is loaded automatically using the "name" to look up information in the yukki.conf.


This is the path to the repository. It is located using the repository_path and repository keys in the configuration.


This is a Git::Repository object which helps us do the real work.



This is the author name to use when making changes to the repository.

This is taken from the author_name of the anonymous key in the configuration or defaults to "Anonymous".


This is the author email to use when making changes to the repository.

This is taken from teh author_email of the anonymous key in the configuration or defaults to "anonymous@localhost".


  my $tree_id = $repository->make_tree($old_tree_id, \@parts, $object_id);
  my $tree_id = $repository->make_tree($old_tree_id, \@parts);
  my $tree_id = $repository->make_tree(
      $old_tree_id, \@old_parts, \@new_parts, $object_id); 

In any case described here, the method returns the object ID of the top level tree created.


When $object_id is given, this will construct one or more trees in the git repository to place the $object_id into the deepest tree. This starts by reading the tree found using the object ID in $old_tree_id. The first path part in @parts is shifted off. If an existing path is found there, that path will be replaced. If not, a new path will be added. A tree object will be constructed for all byt he final path part in @parts.

When the final part is reached, that path will be placed into the final tree as a blob using the given $object_id.

This method will fail if it runs into a situation where a blob would be replaced by a tree or a tree would be replaced by a blob.


When $object_id is not passed or undef, this will cause the final tree or blob found to be removed. This works essentially the same as the case for storing a blob, but when it gets to the last tree or blob found, it will elide that name from the final tree constructed.

This method will fail if you attempt to remove something that does not exist.


When a second array reference is passed with the $object_id, this method will perform a rename. In this case, the method will remove the path named in the @old_parts and add the path named in <@new_parts> using the given $object_id at that new location.

This method will fail if a failure condition that would occur during either the insert/update or remove operation that is being performed simultaneously.


  my $object_id = $repository->make_blob($name, $content);

This creates a new file blob in the git repository with the given name and the file contents.


  my $object_id = $repository->make_blob_from_file($name, $filename);

This is identical to "make_blob", except that the contents are read from the given filename on the local disk.


  my $tree_id = $repository->find_root;

This returns the object ID for the tree at the root of the "branch".


  my $commit_id = $self->commit_tree($old_tree_id, $new_tree_id, $comment);

This takes an existing tree commit (generally found with "find_root"), a new tree to replace it (generally constructed by "make_tree") and creates a commit using the given comment.

The object ID of the committed ID is returned.


  $self->update_root($old_tree_id, $new_tree_id);

Given a old commit ID and a new commit ID, this moves the HEAD of the "branch" so that it points to the new commit. This is called after "commit_tree" has setup the commit.


  my $object_id = $self->find_path($path);

Given a path within the repository, this will find the object ID of that tree or blob at that path for the "branch".


  my $content = $repository->show($object_id);

Returns the contents of the blob for the given object ID.


  my $bytes = $repository->fetch_size($path);

Returns the size, in bites, of the blob at the given path.


  my @files = $repository->list_files($path);

Returns a list of Yukki::Model::File objects for all the files found at $path in the repository.


  my $file = $repository->file({ path => 'foo', filetype => 'yukki' });

Returns a single Yukki::Model::File object for the given path and filetype.


  my $file = $repository->default_file;

Return the default Yukki::Model::File configured for this repository.


  my @log = $repository->log( full_path => 'foo.yukk' );

Returns a list of revisions. Each revision is a hash with the following keys:


The object ID of the commit.


The name of the commti author.


The date the commit was made.


A string showing how long ago the edit took place.


The comment the author made about the comment.


Number of lines added.


Number of lines removed.


  my @chunks = $self->diff_blobs('file.yukki', 'a939fe...', 'b7763d...');

Given a file path and two object IDs, returns a list of chunks showing the difference between to revisions of that path. Each chunk is a two element array. The first element is the type of chunk and the second is any detail for that chunk.

The types are:

    "+"    This chunk was added to the second revision.
    "-"    This chunk was removed in the second revision.
    " "    This chunk is the same in both revisions.


Andrew Sterling Hanenkamp <>


This software is copyright (c) 2014 by Qubling Software LLC.

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