diff options
| author | Joe Perches <joe@perches.com> | 2009-12-14 21:00:50 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:29 -0500 |
| commit | 60db31ac11e2fa35b1c343e7182fb59452c4e52e (patch) | |
| tree | 18bb51d505c8f92e6331999a1462b5fbde18cf3f /scripts | |
| parent | a8af2430f3fb997951eff3d0d51cb166b399782b (diff) | |
scripts/get_maintainer.pl: support multiple VCSs - add mercurial
Restructure a bit for multiple version control systems support.
Use a hash for each supported VCS that contains the commands
and patterns used to find commits, logs, and signers.
--git command line options are still used for hg except for
--git-since. Use --hg-since instead.
The number of commits can differ for git and hg, so --rolestats
might be different.
Style changes: Use common push style push(@foo...), simplify a return
Bumped version to 0.23.
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Marti Raudsepp <marti@juffo.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/get_maintainer.pl | 261 |
1 files changed, 168 insertions, 93 deletions
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index fe91a984247b..445e8845f0a4 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | use strict; | 13 | use strict; |
| 14 | 14 | ||
| 15 | my $P = $0; | 15 | my $P = $0; |
| 16 | my $V = '0.22'; | 16 | my $V = '0.23'; |
| 17 | 17 | ||
| 18 | use Getopt::Long qw(:config no_auto_abbrev); | 18 | use Getopt::Long qw(:config no_auto_abbrev); |
| 19 | 19 | ||
| @@ -23,13 +23,14 @@ my $email_usename = 1; | |||
| 23 | my $email_maintainer = 1; | 23 | my $email_maintainer = 1; |
| 24 | my $email_list = 1; | 24 | my $email_list = 1; |
| 25 | my $email_subscriber_list = 0; | 25 | my $email_subscriber_list = 0; |
| 26 | my $email_git = 1; | ||
| 27 | my $email_git_penguin_chiefs = 0; | 26 | my $email_git_penguin_chiefs = 0; |
| 27 | my $email_git = 1; | ||
| 28 | my $email_git_blame = 0; | ||
| 28 | my $email_git_min_signatures = 1; | 29 | my $email_git_min_signatures = 1; |
| 29 | my $email_git_max_maintainers = 5; | 30 | my $email_git_max_maintainers = 5; |
| 30 | my $email_git_min_percent = 5; | 31 | my $email_git_min_percent = 5; |
| 31 | my $email_git_since = "1-year-ago"; | 32 | my $email_git_since = "1-year-ago"; |
| 32 | my $email_git_blame = 0; | 33 | my $email_hg_since = "-365"; |
| 33 | my $email_remove_duplicates = 1; | 34 | my $email_remove_duplicates = 1; |
| 34 | my $output_multiline = 1; | 35 | my $output_multiline = 1; |
| 35 | my $output_separator = ", "; | 36 | my $output_separator = ", "; |
| @@ -66,15 +67,44 @@ my $penguin_chiefs = "\(" . join("|",@penguin_chief_names) . "\)"; | |||
| 66 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; | 67 | my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])"; |
| 67 | my $rfc822_char = '[\\000-\\377]'; | 68 | my $rfc822_char = '[\\000-\\377]'; |
| 68 | 69 | ||
| 70 | # VCS command support: class-like functions and strings | ||
| 71 | |||
| 72 | my %VCS_cmds; | ||
| 73 | |||
| 74 | my %VCS_cmds_git = ( | ||
| 75 | "execute_cmd" => \&git_execute_cmd, | ||
| 76 | "available" => '(which("git") ne "") && (-d ".git")', | ||
| 77 | "find_signers_cmd" => "git log --since=\$email_git_since -- \$file", | ||
| 78 | "find_commit_signers_cmd" => "git log -1 \$commit", | ||
| 79 | "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file", | ||
| 80 | "blame_file_cmd" => "git blame -l \$file", | ||
| 81 | "commit_pattern" => "^commit [0-9a-f]{40,40}", | ||
| 82 | "blame_commit_pattern" => "^([0-9a-f]+) " | ||
| 83 | ); | ||
| 84 | |||
| 85 | my %VCS_cmds_hg = ( | ||
| 86 | "execute_cmd" => \&hg_execute_cmd, | ||
| 87 | "available" => '(which("hg") ne "") && (-d ".hg")', | ||
| 88 | "find_signers_cmd" => | ||
| 89 | "hg log --date=\$email_hg_since" . | ||
| 90 | " --template='commit {node}\\n{desc}\\n' -- \$file", | ||
| 91 | "find_commit_signers_cmd" => "hg log --template='{desc}\\n' -r \$commit", | ||
| 92 | "blame_range_cmd" => "", # not supported | ||
| 93 | "blame_file_cmd" => "hg blame -c \$file", | ||
| 94 | "commit_pattern" => "^commit [0-9a-f]{40,40}", | ||
| 95 | "blame_commit_pattern" => "^([0-9a-f]+):" | ||
| 96 | ); | ||
| 97 | |||
| 69 | if (!GetOptions( | 98 | if (!GetOptions( |
| 70 | 'email!' => \$email, | 99 | 'email!' => \$email, |
| 71 | 'git!' => \$email_git, | 100 | 'git!' => \$email_git, |
| 101 | 'git-blame!' => \$email_git_blame, | ||
| 72 | 'git-chief-penguins!' => \$email_git_penguin_chiefs, | 102 | 'git-chief-penguins!' => \$email_git_penguin_chiefs, |
| 73 | 'git-min-signatures=i' => \$email_git_min_signatures, | 103 | 'git-min-signatures=i' => \$email_git_min_signatures, |
| 74 | 'git-max-maintainers=i' => \$email_git_max_maintainers, | 104 | 'git-max-maintainers=i' => \$email_git_max_maintainers, |
| 75 | 'git-min-percent=i' => \$email_git_min_percent, | 105 | 'git-min-percent=i' => \$email_git_min_percent, |
| 76 | 'git-since=s' => \$email_git_since, | 106 | 'git-since=s' => \$email_git_since, |
| 77 | 'git-blame!' => \$email_git_blame, | 107 | 'hg-since=s' => \$email_hg_since, |
| 78 | 'remove-duplicates!' => \$email_remove_duplicates, | 108 | 'remove-duplicates!' => \$email_remove_duplicates, |
| 79 | 'm!' => \$email_maintainer, | 109 | 'm!' => \$email_maintainer, |
| 80 | 'n!' => \$email_usename, | 110 | 'n!' => \$email_usename, |
| @@ -309,11 +339,11 @@ foreach my $file (@files) { | |||
| 309 | } | 339 | } |
| 310 | 340 | ||
| 311 | if ($email && $email_git) { | 341 | if ($email && $email_git) { |
| 312 | git_file_signoffs($file); | 342 | vcs_file_signoffs($file); |
| 313 | } | 343 | } |
| 314 | 344 | ||
| 315 | if ($email && $email_git_blame) { | 345 | if ($email && $email_git_blame) { |
| 316 | git_assign_blame($file); | 346 | vcs_file_blame($file); |
| 317 | } | 347 | } |
| 318 | } | 348 | } |
| 319 | 349 | ||
| @@ -403,8 +433,9 @@ MAINTAINER field selection options: | |||
| 403 | --git-min-signatures => number of signatures required (default: 1) | 433 | --git-min-signatures => number of signatures required (default: 1) |
| 404 | --git-max-maintainers => maximum maintainers to add (default: 5) | 434 | --git-max-maintainers => maximum maintainers to add (default: 5) |
| 405 | --git-min-percent => minimum percentage of commits required (default: 5) | 435 | --git-min-percent => minimum percentage of commits required (default: 5) |
| 406 | --git-since => git history to use (default: 1-year-ago) | ||
| 407 | --git-blame => use git blame to find modified commits for patch or file | 436 | --git-blame => use git blame to find modified commits for patch or file |
| 437 | --git-since => git history to use (default: 1-year-ago) | ||
| 438 | --hg-since => hg history to use (default: -365) | ||
| 408 | --m => include maintainer(s) if any | 439 | --m => include maintainer(s) if any |
| 409 | --n => include name 'Full Name <addr\@domain.tld>' | 440 | --n => include name 'Full Name <addr\@domain.tld>' |
| 410 | --l => include list(s) if any | 441 | --l => include list(s) if any |
| @@ -437,8 +468,8 @@ Notes: | |||
| 437 | directory are examined as git recurses directories. | 468 | directory are examined as git recurses directories. |
| 438 | Any specified X: (exclude) pattern matches are _not_ ignored. | 469 | Any specified X: (exclude) pattern matches are _not_ ignored. |
| 439 | Used with "--nogit", directory is used as a pattern match, | 470 | Used with "--nogit", directory is used as a pattern match, |
| 440 | no individual file within the directory or subdirectory | 471 | no individual file within the directory or subdirectory |
| 441 | is matched. | 472 | is matched. |
| 442 | Used with "--git-blame", does not iterate all files in directory | 473 | Used with "--git-blame", does not iterate all files in directory |
| 443 | Using "--git-blame" is slow and may add old committers and authors | 474 | Using "--git-blame" is slow and may add old committers and authors |
| 444 | that are no longer active maintainers to the output. | 475 | that are no longer active maintainers to the output. |
| @@ -449,6 +480,12 @@ Notes: | |||
| 449 | not the percentage of the entire file authored. # of commits is | 480 | not the percentage of the entire file authored. # of commits is |
| 450 | not a good measure of amount of code authored. 1 major commit may | 481 | not a good measure of amount of code authored. 1 major commit may |
| 451 | contain a thousand lines, 5 trivial commits may modify a single line. | 482 | contain a thousand lines, 5 trivial commits may modify a single line. |
| 483 | If git is not installed, but mercurial (hg) is installed and an .hg | ||
| 484 | repository exists, the following options apply to mercurial: | ||
| 485 | --git, | ||
| 486 | --git-min-signatures, --git-max-maintainers, --git-min-percent, and | ||
| 487 | --git-blame | ||
| 488 | Use --hg-since not --git-since to control date selection | ||
| 452 | EOT | 489 | EOT |
| 453 | } | 490 | } |
| 454 | 491 | ||
| @@ -807,44 +844,37 @@ sub mailmap { | |||
| 807 | return @lines; | 844 | return @lines; |
| 808 | } | 845 | } |
| 809 | 846 | ||
| 810 | my $printed_nogit = 0; | 847 | sub git_execute_cmd { |
| 811 | my $printed_nogitdir = 0; | 848 | my ($cmd) = @_; |
| 812 | sub has_git { | 849 | my @lines = (); |
| 813 | if (which("git") eq "") { | ||
| 814 | if (!$printed_nogit) { | ||
| 815 | warn("$P: git not found. Add --nogit to options?\n"); | ||
| 816 | $printed_nogit = 1; | ||
| 817 | } | ||
| 818 | return 0; | ||
| 819 | } | ||
| 820 | if (!(-d ".git")) { | ||
| 821 | if (!$printed_nogitdir) { | ||
| 822 | warn(".git directory not found. " | ||
| 823 | . "Using a git repository produces better results.\n"); | ||
| 824 | warn("Try Linus Torvalds' latest git repository using:\n"); | ||
| 825 | warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n"); | ||
| 826 | $printed_nogitdir = 1; | ||
| 827 | } | ||
| 828 | return 0; | ||
| 829 | } | ||
| 830 | 850 | ||
| 831 | return 1; | 851 | my $output = `$cmd`; |
| 852 | $output =~ s/^\s*//gm; | ||
| 853 | @lines = split("\n", $output); | ||
| 854 | |||
| 855 | return @lines; | ||
| 832 | } | 856 | } |
| 833 | 857 | ||
| 834 | sub git_find_signers { | 858 | sub hg_execute_cmd { |
| 835 | my ($cmd) = @_; | 859 | my ($cmd) = @_; |
| 860 | my @lines = (); | ||
| 861 | |||
