File Coverage

blib/lib/App/Greple/git.pm
Criterion Covered Total %
statement 17 26 65.3
branch 0 4 0.0
condition 0 3 0.0
subroutine 6 7 85.7
pod 0 1 0.0
total 23 41 56.1


line stmt bran cond sub pod time code
1             package App::Greple::git;
2              
3             our $VERSION = "1.00";
4              
5 1     1   328718 use v5.14;
  1         4  
6 1     1   7 use warnings;
  1         2  
  1         95  
7              
8 1     1   782 use Data::Dumper;
  1         10679  
  1         101  
9 1     1   658 use App::Greple::Common;
  1         530  
  1         73  
10 1     1   8 use List::Util qw(any);
  1         2  
  1         81  
11              
12 1     1   611 use File::Spec::Functions qw(canonpath);
  1         1055  
  1         315  
13             *canon = \&canonpath;
14              
15             sub git_file_or_die {
16 0     0 0   my %arg = @_;
17 0 0         my $name = delete $arg{&FILELABEL} or die;
18 0           my $path = canon($name);
19 0   0       state $git_files //= do {
20 0           my @files = `git ls-files`;
21 0           chomp @files;
22 0           +{ map { canon($_) => 1 } @files };
  0            
23             };
24 0 0         $git_files->{$path} or die "SKIP $name";
25             }
26              
27             1;
28              
29             =encoding utf-8
30              
31             =head1 NAME
32              
33             git - Greple git module
34              
35             =head1 SYNOPSIS
36              
37             greple -Mgit ...
38              
39             =head1 VERSION
40              
41             Version 1.00
42              
43             =head1 DESCRIPTION
44              
45             App::Greple::git is a greple module to support git command
46              
47             =head1 OPTIONS
48              
49             =over 4
50              
51             =item B<--color-blame-line>, B<--color-blame>
52              
53             =item B<--color-blame-label>
54              
55             Read L output and apply unique color for each commit
56             id. Option B<--color-blame> and B<--color-blame-line> colorize whole
57             line, while B<--color-blame-label> does only labels.
58              
59             Set F<$HOME/.gitconfig> like this:
60              
61             [pager]
62             blame = greple -Mgit --color-blame-line | env LESSANSIENDCHARS=mK less -cR
63              
64             =begin html
65              
66            

67              
68             =end html
69              
70             =begin html
71              
72            

73              
74             =end html
75              
76             =item B<--color-blame-by-author>
77              
78             Read L output and apply unique color for each author.
79              
80             =item B<--color-header-by-author>
81              
82             Colorize the commit header in a different color based on the author field.
83              
84             =item B<--color-header-by-field> I
85              
86             Generic version of log header colorization. Take a case-insensitive
87             field name as a parameter. B<--color-header-by-author> is defined as
88             follows:
89              
90             option --color-header-by-author --color-header-by-field Author
91              
92             =item B<--only-git-files>
93              
94             Only files under git control from a given file are processed, all
95             other files are ignored. This option is intended to be used in
96             combination with B<--glob> or other options that allow many files to
97             be processed at once. To target all files under git control, use the
98             B<--git> option in the B<-Mdig> module.
99              
100             =back
101              
102             =head1 ENVIRONMENT
103              
104             =over 4
105              
106             =item B
107              
108             =item B
109              
110             Since B produces ANSI Erase Line terminal sequence, it is
111             convenient to set B command understand them.
112              
113             LESS=-cR
114             LESSANSIENDCHARS=mK
115              
116             =back
117              
118             =head1 INSTALL
119              
120             =head2 CPANMINUS
121              
122             $ cpanm App::Greple::git
123              
124             =head1 SEE ALSO
125              
126             L
127              
128             L: git diff support
129              
130             =head1 AUTHOR
131              
132             Kazumasa Utashiro
133              
134             =head1 LICENSE
135              
136             Copyright 2021-2024 Kazumasa Utashiro.
137              
138             This library is free software; you can redistribute it and/or modify
139             it under the same terms as Perl itself.
140              
141             =cut
142              
143             __DATA__