App-GitHooks-Plugin-ForceRegularUpdate
view release on metacpan or search on metacpan
lib/App/GitHooks/Plugin/ForceRegularUpdate.pm view on Meta::CPAN
package App::GitHooks::Plugin::ForceRegularUpdate;
use strict;
use warnings;
use base 'App::GitHooks::Plugin';
# External dependencies.
use Carp;
use File::Slurp ();
# Internal dependencies.
use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES );
=head1 NAME
App::GitHooks::Plugin::ForceRegularUpdate - Force running a specific tool at regular intervals.
=head1 DESCRIPTION
# TODO: description of how to write a tool that generates the timestamp file.
=head1 VERSION
Version 1.0.5
=cut
our $VERSION = '1.0.5';
=head1 CONFIGURATION OPTIONS
This plugin supports the following options in the C<[BlockProductionCommits]>
section of your C<.githooksrc> file.
[BlockProductionCommits]
max_update_age = 2 * 24 * 3600 # 2 days
description = ./my_updater.sh
env_variable = my_environment
env_safe_regex = /^development$/
update_file = /var/local/.last_update.txt
=head2 max_update_age
This indicates the maximum amount of time that may have elapsed since the last
update, before commits are blocked.
max_update_age = 2 * 24 * 3600 # 2 days
Note that this configuration option supports comments at the end, for
readability.
=head2 description
The name of the tool to run to perform an update that will reset the time
counter.
description = ./my_updater.sh
=head2 env_variable
Optional, the name of the environment variable to use to determine the
environment (production, staging, development, etc).
env_variable = my_environment
=head2 env_regex
Optional, but required if C<env_variable> is used.
A regular expression that indicates that this plugin should be run when it is
matched.
env_safe_regex = /^development$/
The example above only checks for regular updates when
C<$ENV{'my_environment'} =~ /^development$/>.
=head2 update_file
The path to the file that stores the unix time of the last upgrade. This is the
file your update tool should write the current unix time to upon successful
completion.
update_file = /var/local/.last_update.txt
Note that you can use an absolute path, or a relative path. If relative, the
path will be relative to the root of the current git repository.
=head1 METHODS
=head2 run_pre_commit()
Code to execute as part of the pre-commit hook.
my $success = App::GitHooks::Plugin::ForceRegularUpdate->run_pre_commit();
=cut
sub run_pre_commit
{
( run in 2.074 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )