NAME

App::SCM::Digest

SYNOPSIS

my $digest = App::SCM::Digest->new($config);
$digest->update();
$digest->get_email();

DESCRIPTION

Provides for sending source control management (SCM) repository commit digest emails. It does this based on the time when the commit was pulled into the local repository, rather than when the commit was committed, so that for a particular time period, the relevant set of commits remains the same.

CONFIGURATION

The configuration hashref is like so:

db_path         => "/path/to/db",
repository_path => "/path/to/local/repositories",
timezone        => "local",
ignore_errors   => 0,
headers => {
    from => "From Address <from@example.org>",
    to   => "To Address <to@example.org>",
    ...
},
repositories => [
    { name => 'test',
      url  => 'http://example.org/path/to/repository',
      type => ['git'|'hg'] },
    { name => 'local-test',
      url  => 'file:///path/to/repository',
      type => ['git'|'hg'] },
    ...
]

The commit pull times for each of the repositories are stored in db_path, which must be a directory.

The local copies of the repositories are stored in repository_path, which must also be a directory.

The timezone entry is optional, and defaults to 'UTC'. It must be a valid constructor value for DateTime::TimeZone. See DateTime::TimeZone::Catalog for a list of valid options.

ignore_errors is an optional boolean, and defaults to false. If false, errors will cause methods to die immediately. If true, errors will instead be printed to stderr, and the method will continue onto the next repository.

App::SCM::Digest clones local copies of the repositories into the repository_path directory. These local copies should not be used except by App::SCM::Digest.

CONSTRUCTOR

new

Takes a configuration hashref, as per CONFIGURATION as its single argument. Returns a new instance of App::SCM::Digest.

PUBLIC METHODS

update

Initialises and updates the local commit databases for each repository-branch pair. These databases record the time at which each commit was received.

When initialising a particular database, only the latest commit is stored. Subsequent updates record all subsequent commits.

get_email

Takes two date strings with the format '%Y-%m-%dT%H:%M:%S', representing the lower and upper bounds of a time period, as its arguments. Returns an Email::MIME object containing all of the commits pulled within that time period, using the details from the headers entry in the configuration to construct the email.

AUTHOR

Tom Harrison, <tomhrr at cpan.org>

COPYRIGHT AND LICENCE

Copyright (C) 2015-2024 Tom Harrison

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.