package VCI::Abstract::Commit; use Moose; use VCI::Util; use VCI::Abstract::Diff; with 'VCI::Abstract::FileContainer'; # All of this crazy init_arg stuff means "coerce lazily, because # DateTime is slow." has 'time' => (is => 'ro', isa => 'VCI::Type::DateTime', coerce => 1, lazy => 1, default => sub { shift->_time }, init_arg => '__time'); has '_time' => (is => 'ro', isa => 'Defined', init_arg => 'time', required => 1); # XXX Git differentiates between Author and Committer, maybe this would be # a useful distinction for us? has 'committer' => (is => 'ro', isa => 'Str', default => sub { '' }); has 'added' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]', lazy_build => 1); has 'removed' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]', lazy_build => 1); has 'modified' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]', lazy_build => 1); has 'moved' => (is => 'ro', isa => 'HashRef', lazy_build => 1); has 'copied' => (is => 'ro', isa => 'HashRef', lazy_build => 1); has 'revision' => (is => 'ro', isa => 'Str', required => 1); # XXX Probably should also have shortmessage, which can be the "subject" # for VCSes that store that, and the first line of the message for # VCSes that don't. has 'message' => (is => 'ro', isa => 'Str', default => sub { '' }); # XXX This should really be being enforced by FileContainer, but see the # note there. has 'project' => (is => 'ro', isa => 'VCI::Abstract::Project', required => 1); has 'as_diff' => (is => 'ro', isa => 'VCI::Abstract::Diff', lazy_build => 1); sub _build_added { [] } sub _build_removed { [] } sub _build_modified { [] } sub _build_moved { {} } sub _build_copied { {} } sub _build_contents { my $self = shift; return [@{$self->added}, @{$self->removed}, @{$self->modified}]; } # as_patch, as_bundle # Also as_patch_binary, as_bundle_binary? # And perhaps as_diff_from, as_bundle_from __PACKAGE__->meta->make_immutable; 1; __END__ =head1 NAME VCI::Abstract::Commit - Represents a single atomic commit to the repository. =head1 DESCRIPTION Usually, when you modify a repository in version control, you modify many files simultaneously in a single "commit" (also called a "checkin"). This object represents one of those commits in the history of a project. Some version-control systems don't actually understand the idea of an "atomic commit" (meaning they don't understand that certain changes were all committed simultaneously), but VCI does its best to figure out what files were committed together and represent them all as one object. A L implements L, so all of FileContainer's methods are also available here. B: Depending on how this object was constructed, it may or may not actually contain information on all of the files that were committed in this change. For example, when you use L, Commit objects might only contain information about that single file. This is due to the limits of various version-control systems. =head1 METHODS =head2 Accessors These are all read-only. =over =item C, L, and L. If L and L aren't specified, they default to an empty string. =back