summaryrefslogtreecommitdiffstats
path: root/src/lib/Gitolite/Triggers.pm
blob: 16e8aa651e5c5eaa01a2b925e2e4c722141726b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Gitolite::Triggers;

# load and run triggered modules
# ----------------------------------------------------------------------

#<<<
@EXPORT = qw(
);
#>>>
use Exporter 'import';

use Gitolite::Rc;
use Gitolite::Common;

use strict;
use warnings;

# ----------------------------------------------------------------------

sub run {
    my ( $module, $sub, @args ) = @_;
    $module = "Gitolite::Triggers::$module" if $module !~ /^Gitolite::/;

    eval "require $module";
    _die "$@" if $@;
    my $subref;
    eval "\$subref = \\\&$module" . "::" . "$sub";
    _die "module '$module' does not exist or does not have sub '$sub'" unless ref($subref) eq 'CODE';

    $subref->(@args);
}

1;