#!/usr/bin/perl # Update SLOCcount page... my $outputFilename = ""; my @gitRemoteBranches = (); my $avgSalary = 120000; for ($i = 0; $i < @ARGV; ++$i) { if ($ARGV[$i] eq "-restricted") { $outputFilename = "slocCountFR.html"; @gitRemoteBranches = `git ls-remote --heads ssh://git.sl.int/git-restricted`; } elsif (($ARGV[$i] eq "-salary") && (($i + 1) < @ARGV)) { ++$i; $avgSalary = $ARGV[$i]; } } if ($outputFilename eq "") { $outputFilename = "slocCount.html"; @gitRemoteBranches = `git ls-remote --heads ssh://git.sl.int/git`; } my @remoteBranches = (); #my @remoteResBranches = (); foreach my $remoteBranch (@gitRemoteBranches) { chomp $remoteBranch; $remoteBranch =~ s/^.*refs\/heads\///g; if (($remoteBranch =~ /^develop/) || ($remoteBranch =~ /^master/) || ($remoteBranch =~ /^release/)) { push @remoteBranches, $remoteBranch; } } #foreach my $remoteResBranch (@gitRemoteRestrictedBranches) #{ # chomp $remoteResBranch; # $remoteResBranch =~ s/^.*refs\/heads\///g; # # if (($remoteResBranch =~ /^develop/) || # ($remoteResBranch =~ /^master/) || # ($remoteResBranch =~ /^release/)) # { # push @remoteResBranches, $remoteResBranch; # } #} my $contentsBlock = ""; my $linkBlock = ""; if (open(SLOC_FILE, ">$outputFilename")) { print SLOC_FILE < Sequence Logic Source Lines of Code ENDOFHEADER print SLOC_FILE "

Date generated: "; print SLOC_FILE `date`; print SLOC_FILE "

\n"; foreach my $remoteBranch (@remoteBranches) { $contentsBlock .= "
  • $remoteBranch
  • "; $linkBlock .= "

    Branch: $remoteBranch

    \n"; `git checkout $remoteBranch`; `git pull`; my @projectList = `ls -1`; my $projects = ""; foreach $project (@projectList) { chomp $project; if (($project ne "cppboost") && ($project ne "SLSync") && ($project ne "thirdparty")) { $projects .= " $project"; } } print "Found projects: $projects\n"; my @slocOutput = `sloccount --personcost $avgSalary $projects`; my $startOutput = 0; #print SLOC_FILE "
    \n";
            $linkBlock .= "
    \n";
            foreach $slocOutLine (@slocOutput)
            {
                chomp $slocOutLine;
                if (($startOutput == 0) && ($slocOutLine ne "Computing results."))
                {
                    next;
                }
                $startOutput = 1;
                #print SLOC_FILE "$slocOutLine\n";
                $linkBlock .= "$slocOutLine\n";
            }
            #print SLOC_FILE "
    \n"; $linkBlock .= "
    \n

    \n"; } print SLOC_FILE $contentsBlock; print SLOC_FILE $linkBlock; print SLOC_FILE < ENDOFFOOTER close SLOC_FILE; }