commit 8b806913a09bc9b48758bf01d952547845e5e339
Author: Simon Watson <swatson@datto.com>
Date: Mon May 20 19:25:14 2019 -0400
Saving work in progress
diff --git a/.sg/sgLog.txt b/.sg/sgLog.txt
index e69de29..b16f447 100644
--- a/.sg/sgLog.txt
+++ b/.sg/sgLog.txt
@@ -0,0 +1 @@
+2019/05/20 17:26:32 ERROR /usr/bin/wc -l . returned non-zero: 256
diff --git a/lib/SimplyGit/Git.pm b/lib/SimplyGit/Git.pm
index e3ee858..b69a246 100644
--- a/lib/SimplyGit/Git.pm
+++ b/lib/SimplyGit/Git.pm
@@ -15,8 +15,13 @@ sub readConfig {
my $path = shift;
my $logger = shift;
if ( ! -d $path ) {
- $logger->error("$path doesn't look like a dir, exiting...");
- exit 1;
+ if ( defined $logger && $logger ne "" ) {
+ $logger->error("$path doesn't look like a dir, exiting...");
+ exit 1;
+ } else {
+ print "Failed and no logger passed, exiting...\n";
+ exit 1;
+ }
}
my $gitConfigPath = $path . "/" . ".git/config";
my $catCmd = findBin("cat",$logger);
@@ -34,17 +39,31 @@ sub readConfig {
}
+ my $wcBin = findBin("wc",$logger);
+ # TODO: Clean shell call up
+ my $lastLine = shellex("$wcBin -l $gitConfigPath | awk '{print \$1}'",$logger);
+ chomp $lastLine;
my @lineRange = values %gitConfig;
+ push(@lineRange, $lastLine);
my @sortedRange = sort { $a <=> $b } @lineRange;
- my $prevVal ;
+ my $prevVal;
foreach my $val ( @sortedRange ) {
+ my @stash;
print "Val is $val\n";
if ( ! defined $prevVal ) {
$prevVal = $val;
next;
} else {
print "Current var is $val and prevVar $prevVal\n";
- my $lineDiff = ( $val - 1 ) . "-" . ( $prevVal + 1 );
+ my $lineDiff = ( $prevVal + 1 ) . "-" . ( $val - 1 );
+ my $lineCounter = 0;
+ foreach my $line ( @configLines ) {
+ $lineCounter++;
+ #if ( $lineCounter >= ( $prevVal + 1 ) && $lineCounter <= ( $val - 1 ) ) {
+ if ( $lineCounter >= $prevVal && $lineCounter <= $val ) {
+ print "$line\n";
+ }
+ }
print "lineDiff of vals is: $lineDiff \n";
$prevVal = $val;
}