This file is indexed.

/usr/share/perl5/Dist/Zilla/Role/GitConfig.pm is in libdist-zilla-plugin-config-git-perl 0.92-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package Dist::Zilla::Role::GitConfig;

our $VERSION = '0.92'; # VERSION
# ABSTRACT: Easy role to add git_config option to most plugins

#############################################################################
# Modules

use Moose::Role;
use MooseX::Types::Moose qw(Str RegexpRef);

use List::Util qw(first);

use String::Errf qw(errf);  # We are here to save the errf: E-R-R-F!

use namespace::clean;

#############################################################################
# Requirements

requires qw(log_fatal zilla _git_config_mapping);

#############################################################################
# Attributes

has git_config => (
   is        => 'ro',
   isa       => Str,
);

#############################################################################
# Pre/post-BUILD

around BUILDARGS => sub {
   my $orig = shift;
   my $self = shift;
   my %opts = @_ == 1 ? %{$_[0]} : @_;

   my $zilla = $opts{zilla};

   if ($opts{git_config}) {
      my $config = first {
         $_->isa('Dist::Zilla::Plugin::Config::Git') && $_->plugin_name eq $opts{git_config}
      } @{ $zilla->plugins };

      $self->log_fatal(['No Config::Git plugin found called "%s"', $opts{git_config}])
         unless $config;

      my $mapping = $self->_git_config_mapping;
      my @mvps    = $self->can('mvp_multivalue_args') ? $self->mvp_multivalue_args : ();

      # Map configuration to different attributes
      foreach my $option (sort keys %$mapping) {
         my $errf_str = $mapping->{$option};

         my $val = errf $errf_str, {
            map { $_ => $config->$_() } qw( remote local_branch remote_branch changelog )
         };

         # Don't overwrite if option already exists
         unless (exists $opts{$option}) {
            $opts{$option} = (grep { $_ eq $option } @mvps) ? [ $val ] : $val;
         }
      }

      ### XXX: This should probably be more dynamic...
      if ($self->can('allow_dirty') && !exists $opts{'allow_dirty'}) {
         if ($self->can('allow_dirty_match')) {
            $opts{'allow_dirty'}       = [ grep {       Str->check($_) } @{ $config->allow_dirty } ];
            $opts{'allow_dirty_match'} = [ grep { RegexpRef->check($_) } @{ $config->allow_dirty } ];
         }
         else {
            $opts{'allow_dirty'} = [ @{ $config->allow_dirty } ];
         }
      }
   }

   $orig->($self, %opts);
};

42;

__END__

=pod

=encoding UTF-8

=head1 NAME

Dist::Zilla::Role::GitConfig - Easy role to add git_config option to most plugins

=head1 SYNOPSIS

    package Dist::Zilla::Plugin::GitReleasePlugin;
 
    use Moose;
 
    with 'Dist::Zilla::Role::BeforeRelease';
    with 'Dist::Zilla::Role::GitConfig';
 
    sub _git_config_mapping { +{
       push_to   => '%{remote}s %{local_branch}s:%{remote_branch}s',
       changelog => '%{changelog}s',
    } }

=head1 DESCRIPTION

This is an easy-to-use role for plugins to enable usage of L<Config::Git|Dist::Zilla::Plugin::Config::Git> configurations.

=head1 REQUIREMENTS

=head2 _git_config_mapping

Hashref of option to L<errf|String::Errf> string mappings.

The mappings don't work for C<<< allow_dirty >>>.  These are (currently) hardcoded to map to C<<< allow_dirty >>> and C<<< allow_dirty_match >>> options
directly.

=head1 AVAILABILITY

The project homepage is L<https://github.com/SineSwiper/Dist-Zilla-Plugin-Config-Git>.

The latest version of this module is available from the Comprehensive Perl
Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
site near you, or see L<https://metacpan.org/module/Dist::Zilla::Plugin::Config::Git/>.

=head1 AUTHOR

Brendan Byrd <BBYRD@CPAN.org>

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2013 by Brendan Byrd.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

=cut