check_procs: ignore plugin parent process
[monitoring-plugins.git] / tools / generate-change-log
blob03321fd88a18c135610bef037b7a93c887cc380f
1 #!/usr/bin/env perl
3 # Copyright (c) 2013 Nagios Plugins Development Team
5 # Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
7 # This file is free software; the Nagios Plugins Development Team gives
8 # unlimited permission to copy and/or distribute it, with or without
9 # modifications, as long as this notice is preserved.
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY, to the extent permitted by law; without even the implied
13 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 use warnings;
17 use strict;
18 use Text::Wrap;
20 # The lines will have a length of no more than $columns - 1.
21 $Text::Wrap::columns = 81;
23 if (system('git rev-parse --git-dir >/dev/null 2>&1') != 0) {
24 print "Not a Git repository, so I won't update the ChangeLog.\n";
25 exit 0;
28 my $regex =
29 '^commit [0-9a-f]+\n' .
30 '^Author: (?<name>.+) <(?<email>.*)>\n' .
31 '^Date: (?<date>\d{4}-\d{2}-\d{2})\n' .
32 '^\n' .
33 '(?<message>(^ .*\n)+)' .
34 '^\n' .
35 '(?<files>(^.+\n)+)';
37 my $git_log = qx'git log -M -C --stat --name-only --date=short';
38 die "Cannot get `git log' output\n" if $? != 0;
40 my ($prev_date, $prev_name, $prev_email);
42 while ($git_log =~ /$regex/gm) {
43 my %commit = %+;
45 if (not defined $prev_date
46 or $commit{date} ne $prev_date
47 or $commit{name} ne $prev_name
48 or $commit{email} ne $prev_email) {
49 print "$commit{date} $commit{name} <$commit{email}>\n\n";
51 $prev_date = $commit{date};
52 $prev_name = $commit{name};
53 $prev_email = $commit{email};
55 my @files = split(/\n/, $commit{files});
56 my @message = map { s/^ {4}//; $_ } split(/\n/, $commit{message});
57 my $first_line = shift(@message);
58 $first_line =~ s/^$files[-1]: //;
59 my $intro = sprintf('* %s: %s', join(', ', @files), $first_line);
61 print fill("\t", "\t", $intro), "\n";
62 foreach my $line (@message) {
63 print "\t$line" if length($line) > 0;
64 print "\n";
66 print "\n";