From cc10317ec73099cc63835d2600bfd99bb640e6be Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 29 Apr 2016 12:32:42 -0700 Subject: [PATCH] Progress option and use of it. --- extract-code-added-in-commits.plx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/extract-code-added-in-commits.plx b/extract-code-added-in-commits.plx index b047229..2cebd11 100755 --- a/extract-code-added-in-commits.plx +++ b/extract-code-added-in-commits.plx @@ -92,14 +92,15 @@ use POSIX qw(strftime); use Getopt::Long; use Pod::Usage; -my($GIT_REPOSITORY_PATH, $OUTPUT_DIRECTORY, $CENTRAL_COMMIT, $FORK_LIMIT, $VERBOSE, @ADDITIONAL_BLAME_OPTS); -$VERBOSE = 0; +my($GIT_REPOSITORY_PATH, $OUTPUT_DIRECTORY, $CENTRAL_COMMIT, $FORK_LIMIT, $PROGRESS, $VERBOSE, @ADDITIONAL_BLAME_OPTS); +$PROGRESS = $VERBOSE = 0; $FORK_LIMIT = 1; -my $usage = "usage: $0 --repository=PATH --output-dir=DIR [--central-commit=COMMIT-ID] [--fork-limit=NUMBER [--verbose[=LEVEL]]\n"; +my $usage = "usage: $0 --repository=PATH --output-dir=DIR [--central-commit=COMMIT-ID] [--fork-limit=NUMBER [--progress] [--verbose[=LEVEL]]\n"; unless (GetOptions("repository=s" => \$GIT_REPOSITORY_PATH, "output-dir=s" => \$OUTPUT_DIRECTORY, "verbose:+" => \$VERBOSE, + "progress" => \$PROGRESS, "--blame-opts=s" => \@ADDITIONAL_BLAME_OPTS, "central-commit:s" => \$CENTRAL_COMMIT, "fork-limit:i" => \$FORK_LIMIT)) { @@ -220,7 +221,12 @@ sub RunCentralCommitMode($) { } } $SIG{CHLD} = $HANDLE_BLAME_WORKERS_SUB; + my $cnt = scalar(keys %files); + print STDERR "Git blame operations to complete: $cnt\n" if $PROGRESS; foreach my $file (keys %files) { + if ($PROGRESS) { + print STDERR "."; $cnt--; if ($cnt % 100 == 0) { print "\nOperations Remaining: $cnt\n"; } + } my($vv, $path, $filename) = File::Spec->splitpath($file); $path = File::Spec->catfile($centralOutputDir, $path); make_path($path, 0750);