summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2011-04-26 20:03:01 +0200
committerPetr Mladek <pmladek@suse.cz>2011-04-26 20:03:01 +0200
commit33a840056580197ba5c2ea41b19251da3df2809b (patch)
tree00d97e89c77336970030e3f702e8bd77337ce4d9 /bin
parentb3f8d9a9b87dd453b920a969a69835fa2464859e (diff)
lo-commit-stat: detect mismatch of branches between repos
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lo-commit-stat41
1 files changed, 23 insertions, 18 deletions
diff --git a/bin/lo-commit-stat b/bin/lo-commit-stat
index 342d47ae5014..9a1309739084 100755
--- a/bin/lo-commit-stat
+++ b/bin/lo-commit-stat
@@ -67,9 +67,9 @@ sub standardize_summary($)
return $line;
}
-sub load_git_log($$$$)
+sub load_git_log($$$$$)
{
- my ($pdata, $repo_dir, $piece, $pgit_args) = @_;
+ my ($pdata, $repo_dir, $piece, $branch_name, $pgit_args) = @_;
my $cmd = "cd $repo_dir && git log " . join ' ', @{$pgit_args};
my $commit_id;
@@ -77,6 +77,13 @@ sub load_git_log($$$$)
print STDERR "Analyzing log from the git repo: $piece...\n";
+ my $repo_branch_name = get_branch_name($repo_dir);
+ if ( $branch_name ne $repo_branch_name ) {
+ die "Error: mismatch of branches:\n" .
+ " main repo is on the branch: $branch_name\n" .
+ " $piece repo is on the branch: $repo_branch_name\n";
+ }
+
open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!";
%{$pdata->{$piece}} = ();
@@ -144,9 +151,9 @@ sub get_repo_name($)
die "Error: can't find repo name in \"$$repo_dir/.git/config\"\n";
}
-sub load_data($$$$)
+sub load_data($$$$$)
{
- my ($pdata, $top_dir, $piece, $pgit_args) = @_;
+ my ($pdata, $top_dir, $piece, $branch_name, $pgit_args) = @_;
if (defined $piece) {
my $piece_dir;
@@ -155,11 +162,11 @@ sub load_data($$$$)
} else {
$piece_dir = "$top_dir/clone/$piece";
}
- load_git_log($pdata, $piece_dir, $piece, $pgit_args);
+ load_git_log($pdata, $piece_dir, $piece, $branch_name, $pgit_args);
} else {
- load_git_log($pdata, $top_dir, $main_repo, $pgit_args);
+ load_git_log($pdata, $top_dir, $main_repo, $branch_name, $pgit_args);
foreach my $piece (@pieces) {
- load_git_log($pdata, "$top_dir/clone/$piece", $piece, $pgit_args);
+ load_git_log($pdata, "$top_dir/clone/$piece", $piece, $branch_name, $pgit_args);
}
}
}
@@ -171,8 +178,6 @@ sub get_branch_name($)
my $branch;
my $cmd = "cd $top_dir && git branch";
- print STDERR "Analyzing git branch: ";
-
open (GIT, "$cmd 2>&1|") || die "Can't run $cmd: $!";
while (my $line = <GIT>) {
@@ -184,19 +189,16 @@ sub get_branch_name($)
}
close GIT;
-
- die "Error: did not detect git branch name\n" unless defined ($branch);
-
- print STDERR "$branch\n";
+
+ die "Error: did not detect git branch name in $top_dir\n" unless defined ($branch);
return $branch;
}
-sub open_log_file($$$)
+sub open_log_file($$$$)
{
- my ($log_prefix, $log_suffix, $top_dir) = @_;
+ my ($log_prefix, $log_suffix, $top_dir, $branch_name) = @_;
- my $branch_name = get_branch_name($top_dir);
my $logfilename = "$log_prefix-$branch_name-$log_suffix.log";
if (-f $logfilename) {
@@ -328,6 +330,7 @@ my $top_dir;
my $log_prefix = "commit-log";
my $log_suffix;
my $log;
+my $branch_name;
my @git_args;
my %data;
my %print_filters = ();
@@ -360,8 +363,10 @@ foreach my $arg (@ARGV) {
(defined $log_suffix) || die "Error: define log suffix using --log-suffix=<string>\n";
-load_data(\%data, $top_dir,$piece, \@git_args);
+$branch_name = get_branch_name($top_dir);
+
+load_data(\%data, $top_dir, $piece, $branch_name, \@git_args);
-$log = open_log_file($log_prefix, $log_suffix, $top_dir);
+$log = open_log_file($log_prefix, $log_suffix, $top_dir, $branch_name);
print_stat(\%data, \%print_filters, $log);
close $log;