|
@@ -5,17 +5,17 @@ use Log::Log4perl qw(:easy);
|
|
|
use lib ".";
|
|
|
use SimplyGit::Shellex qw(shellex findBin);
|
|
|
use Exporter qw(import);
|
|
|
-our @EXPORT_OK = qw(readConfig getStatus returnState addFiles commitChanges pushChanges stashAndReset);
|
|
|
+our @EXPORT_OK = qw(readConfig getStatus returnState addFiles commitChanges pushChanges stashAndReset resetFromUpstream);
|
|
|
|
|
|
sub readConfig {
|
|
|
|
|
|
- # TODO: This sub is probably not really needed for what I'm trying to do
|
|
|
- # git itself already parses this config...
|
|
|
+ # This sub is probably not really needed for what I'm trying to do
|
|
|
+ # git itself already parses this config...but an interesting exercise non the less
|
|
|
+ # and may be useful later
|
|
|
my $path = shift;
|
|
|
my $logger = shift;
|
|
|
- # TODO: Should pass in logger object as opposed to printing
|
|
|
if ( ! -d $path ) {
|
|
|
- print "readConfig did not recieve expected dir, exiting...\n";
|
|
|
+ $logger->error("$path doesn't look like a dir, exiting...");
|
|
|
exit 1;
|
|
|
}
|
|
|
my $gitConfigPath = $path . "/" . ".git/config";
|
|
@@ -23,17 +23,33 @@ sub readConfig {
|
|
|
my @configLines = split("\n",shellex("$catCmd $gitConfigPath",$logger));
|
|
|
my %gitConfig;
|
|
|
my @valueLines;
|
|
|
- my $headerCounter = 0;
|
|
|
+ my $lineCounter = 0;
|
|
|
foreach my $line ( @configLines ) {
|
|
|
- if ( $line =~ m/\[(.*)\]/ ) {
|
|
|
+ $lineCounter++;
|
|
|
+ #if ( $line =~ m/\[(.*)\]/ ) {
|
|
|
+ if ( $line =~ m/(\[.*\])/ ) {
|
|
|
#$valueLine =~ /\t(.*)\ =\ (.*)$/;
|
|
|
- $gitConfig{$1} = "";
|
|
|
- } else {
|
|
|
- push(@valueLines, $line);
|
|
|
+ $gitConfig{$1} = $lineCounter;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ my @lineRange = values %gitConfig;
|
|
|
+ my @sortedRange = sort { $a <=> $b } @lineRange;
|
|
|
+ my $prevVal ;
|
|
|
+ foreach my $val ( @sortedRange ) {
|
|
|
+ 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 );
|
|
|
+ print "lineDiff of vals is: $lineDiff \n";
|
|
|
+ $prevVal = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return %gitConfig;
|
|
|
|
|
|
}
|
|
@@ -134,5 +150,13 @@ sub stashAndReset {
|
|
|
shellex("$gitCmd rebase",$logger);
|
|
|
}
|
|
|
|
|
|
+sub resetFromUpstream {
|
|
|
|
|
|
+ # git stash and git reset --hard and git pull ? I think
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+sub appendRepoUserConfig {
|
|
|
+
|
|
|
+
|
|
|
+}
|