0b05c202a28faf95ee8426050744afb148eb11cd
commit 0b05c202a28faf95ee8426050744afb148eb11cd
Author: Simon Waton <spw01@protonmail.com>
Date: Tue May 14 22:41:30 2019 -0400

Finalized base functionality

diff --git a/lib/SimplyGit/Git.pm b/lib/SimplyGit/Git.pm
index 6550c9e..67b3657 100644
--- a/lib/SimplyGit/Git.pm
+++ b/lib/SimplyGit/Git.pm
@@ -7,7 +7,7 @@ use SimplyGit::Shellex qw(shellex findBin);
use Exporter qw(import);
our @EXPORT_OK = qw(readConfig getStatus returnState addFiles commitChanges pushChanges);

-sub readConfig($) {
+sub readConfig {

# TODO: This sub is probably not really needed for what I'm trying to do
# git itself already parses this config...
diff --git a/sg b/sg
index 2b51493..3a020df 100755
--- a/sg
+++ b/sg
@@ -10,6 +10,11 @@ use lib "/usr/local/lib";
use SimplyGit::Shellex qw(shellex findBin);
use SimplyGit::Git qw(readConfig getStatus returnState addFiles commitChanges pushChanges);

+if ( ! -d ".git" ) {
+ print "Not a git dir, exiting...\n";
+ exit 1;
+}
+
sub initSG($) {

my $sgDir = shift;
@@ -92,9 +97,13 @@ if ( scalar keys %args < 1 ) {
if ( defined $args{'view'} ) {
my ( $untrackedRef, $modifiedRef, $addedRef, $deletedRef ) = returnState($logger);
my $refs = shellex("$gitCmd show-ref",$logger);
+ my $branch = shellex("$gitCmd show-branch",$logger);
+ print "On [branch] @ commit: $branch";
print "$refs\n";
my $swpWarning = "\t# Likely a Vi .swp file";
- print "Untracked files:\n";
+
+ my $untrackedTotal = scalar @$untrackedRef;
+ print "* $untrackedTotal untracked file(s):\n";
foreach my $file ( @$untrackedRef ) {
if ( $file =~ m/.swp/ ) {
print "\t$file $swpWarning\n";
@@ -102,7 +111,9 @@ if ( defined $args{'view'} ) {
print "\t$file\n";
}
}
- print "Modified files:\n";
+
+ my $modifiedTotal = scalar @$modifiedRef;
+ print "* $modifiedTotal modified file(s):\n";
foreach my $file ( @$modifiedRef ) {
if ( $file =~ m/.swp/ ) {
print "\t$file $swpWarning\n";
@@ -111,7 +122,8 @@ if ( defined $args{'view'} ) {
}
}

- print "Files added to commit:\n";
+ my $commitTotal = scalar @$addedRef;
+ print "* $commitTotal file(s) added to commit:\n";
foreach my $file ( @$addedRef ) {
if ( $file =~ m/.swp/ ) {
print "\t$file $swpWarning\n";
@@ -120,7 +132,8 @@ if ( defined $args{'view'} ) {
}
}

- print "Files to be deleted from commit:\n";
+ my $deletedTotal = scalar @$deletedRef;
+ print "* $deletedTotal file(s) to be deleted from commit:\n";
foreach my $file ( @$deletedRef ) {
if ( $file =~ m/.swp/ ) {
print "\t$file $swpWarning\n";