Browse Source

Finalized base functionality

Simon Waton 5 years ago
parent
commit
0b05c202a2
2 changed files with 18 additions and 5 deletions
  1. 1 1
      lib/SimplyGit/Git.pm
  2. 17 4
      sg

+ 1 - 1
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...

+ 17 - 4
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";