Debian Codegraph @

scripts/gitblame

raw
1 #!/usr/bin/env perl
2
3 # Copyright (c) MediaTek USA Inc., 2020-2023
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or (at
8 # your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see
17 # <http://www.gnu.org/licenses/>.
18 #
19 #
20 # gitblame [--p4] [--prefix path] [--abbrev regexp] [domain] pathname
21 #
22 # This script runs "git blame" for the specified file and formats the result
23 # to match the diffcov(1) age/ownership annotation specification.
24 #
25 # If the '--p4' flag is used:
26 # we assume that the GIT repo is cloned from Perforce - and look for
27 # the line in the generated commit log message which tells us the perforce
28 # changelist ID that we actually want.
29 #
30 # If specified, 'path' is prepended to 'pathname' (as 'path/pathname')
31 # before processing.
32 #
33 # If passed a domain name (or domain regexp):
34 # strip that domain from the author's address, and treat all users outside
35 # the matching domain as "External".
36 # The --abbrev argument enables you to specify one or more regexp patterns
37 # which are used to compute the user name abbreviation that are applied.
38
39 use strict;
40 use FindBin;
41 use lib "$FindBin::RealBin";
42 use gitblame qw(new);
43 use annotateutil qw(call_annotate);
44
45 if (-f $ARGV[-1] || '-' ne index($ARGV[-1], 1)) {
46 call_annotate('gitblame', $0, @ARGV);
47 } else {
48 gitblame->new($0, @ARGV);
49 }