scripts/commit_count/commits.pl
author nithyar
Thu, 15 Apr 2010 16:06:19 +0100
changeset 40 f78be479738b
parent 29 13a99a13ca90
permissions -rwxr-xr-x
Tools updations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     1
#!/usr/bin/perl
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     2
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     3
use Getopt::Long;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     4
my $log_file;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     5
my $log_data;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     6
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     7
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     8
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
     9
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    10
sub printhelp
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    11
{
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    12
  print "\ncounting commits in log file
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    13
  \noptions:
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    14
  \n\t-f (mandaory) mercurial access log file\n";
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    15
  exit;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    16
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    17
}
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    18
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    19
sub cmd_options
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    20
{
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    21
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    22
  my $help;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    23
  
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    24
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    25
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    26
  GetOptions('h' => \$help,'f=s'=> \$log_file);
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    27
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    28
  
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    29
  if ($help) {
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    30
    printhelp;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    31
  }
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    32
  
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    33
  if (not $log_file) {
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    34
    print "ERROR  - LOG File not provided\n ";
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    35
    printhelp;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    36
  }
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    37
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    38
                                    
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    39
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    40
}
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    41
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    42
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    43
#main
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    44
cmd_options();
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    45
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    46
open(DATA, "<".$log_file);
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    47
open(COMMITOUT, ">output_commits.csv");
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    48
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    49
while (<DATA>){
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    50
     $log_data = $_;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    51
     if ($log_data =~ m/POST/ & $log_data =~ m/MCL(.*?)\?.*?\" 200 /)  { 
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    52
        $pkg = $1;
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    53
        if ($log_data =~ m/([0-9]+)\/([A-z]+)\/([0-9]+)/) {
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    54
          
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    55
          $tcommit = $1."-".$2."-".$3;   
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    56
            
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    57
        } else {
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    58
          $tcommit = "NOTFOUND_TIME";
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    59
        }
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    60
        
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    61
        if ($log_data =~ m/(\d+\.\d+\.\d+\.\d+)/) {
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    62
          
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    63
          $ipcommit = $1;   
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    64
            
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    65
        } else {
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    66
          $ipcommit = "NOTFOUND_IP";
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    67
        }
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    68
        
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    69
        
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    70
        print COMMITOUT "$pkg\t$tcommit\t$ipcommit\n"; 
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    71
     }
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    72
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    73
}
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    74
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    75
close (DATA);
13a99a13ca90 added commit count script for appache logs
victorp@symbian.org
parents:
diff changeset
    76
close (COMMITOUT);