From 5491c20e1df0b0a9a994cfa1e4532a3078ad4c19 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> Date: Mon, 3 Oct 2016 07:33:33 +0200 Subject: [PATCH 12/21] releng: Update create_changelog.pl --- releng/create_changelog.pl | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/releng/create_changelog.pl b/releng/create_changelog.pl index e066eaa..19a07e2 100755 --- a/releng/create_changelog.pl +++ b/releng/create_changelog.pl @@ -39,23 +39,46 @@ use strict; use warnings; +use FileHandle; +use Getopt::Long; use Text::Wrap; my %log; +my $optVerbose = 0; sub help { - print "Usage: create-changelog <srcdir> <revision-range>\n" . + print "Usage: create-changelog [OPTIONS] <srcdir> <revision-range>\n" . "\n" . "srcdir the qt source directory\n" . - "revision-range arguments to git log, like v5.0.0..v5.1.0-rc1\n"; + "revision-range arguments to git log, like v5.0.0..v5.1.0-rc1\n" . + "Options:\n" . + " -v Verbose output.\n"; exit 0; } +sub isMasterRepo +{ + my $modulesFileName = '.gitmodules'; + return 0 unless -e $modulesFileName; + my $modulesFile = new IO::File('<' . $modulesFileName) or return 0; + while (my $line = <$modulesFile>) { + if ($line =~ /\[submodule\s*"qtbase"\]/) { + $modulesFile->close(); + return 1; + } + } + $modulesFile->close(); + return 0; +} + sub collect_entries { # Run git submodule foreach chdir(shift @ARGV) if (scalar @ARGV); - my @revListCommand = ("git rev-list --reverse --grep '^\\[ChangeLog\\]' " . $ARGV[0] . - " 2> /dev/null | git cat-file --batch || true"); - unshift(@revListCommand, 'git', 'submodule', 'foreach', '--quiet') if -e '.gitmodules'; + my $cmd = "git rev-list --reverse --grep '^\\[ChangeLog\\]' " . $ARGV[0]; + $cmd .= ' 2> /dev/null' unless $optVerbose; + $cmd .= ' | git cat-file --batch || true'; + my @revListCommand = ($cmd); + unshift(@revListCommand, 'git', 'submodule', 'foreach', '--quiet') if isMasterRepo(); + print STDERR "Running: ", join(' ', @revListCommand), "\n"; open FOREACH, '-|', @revListCommand; # Collect all entries @@ -128,7 +151,7 @@ sub print_entry($%) { print "\n"; } -help() unless scalar @ARGV; +help() unless GetOptions("verbose" => \$optVerbose) && scalar(@ARGV) == 2; # Now print the output collect_entries(); -- 2.10.2