Browse Source

Updated Git.pm with strict sub args

spesk1 5 years ago
parent
commit
20bd74fcfc
2 changed files with 13 additions and 18 deletions
  1. 12 17
      lib/SimplyGit/Git.pm
  2. 1 1
      sg

+ 12 - 17
lib/SimplyGit/Git.pm

@@ -12,23 +12,18 @@ our @EXPORT_OK = qw(readConfig getStatus returnState addFiles commitChanges push
 # and then required the logger object arg for all who don't fit that usecase
 # TODO: Add info/debug logging for all subroutines
 
-sub checkPath {
+sub checkPath($$) {
 
 	my $path = shift;
 	my $logger = shift;
 	if ( ! -d $path ) {
-		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;
-		}
+		$logger->error("$path doesn't look like a dir, exiting...");
+		exit 1;
 	}
 
 }
 
-sub returnConfigPath {
+sub returnConfigPath($$) {
 
 	my $path = shift;
 	my $logger = shift;
@@ -40,7 +35,7 @@ sub returnConfigPath {
 }
 	
 
-sub readConfig {
+sub readConfig($$) {
 
 	# 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
@@ -98,7 +93,7 @@ sub readConfig {
 
 }
 
-sub getStatus {
+sub getStatus($) {
 
 	my $logger = shift;
 	my $gitCmd = findBin("git",$logger);
@@ -108,7 +103,7 @@ sub getStatus {
 
 }
 
-sub returnState {
+sub returnState($) {
 
 	my $logger = shift;
 	my $gitCmd = findBin("git",$logger);
@@ -148,7 +143,7 @@ sub returnState {
 
 }
 
-sub addFiles {
+sub addFiles($$) {
 
 	my $filesToAddRef = shift;
 	my $logger = shift;
@@ -161,7 +156,7 @@ sub addFiles {
 
 # TODO: Possibly worth returning output for commitChanges(), pushChanges(), stashAndReset, even if I'm not using it right now
 
-sub commitChanges {
+sub commitChanges($$) {
 
 	my $commitMsg = shift;
 	chomp $commitMsg;
@@ -171,7 +166,7 @@ sub commitChanges {
 
 }
 
-sub pushChanges {
+sub pushChanges($) {
 
 	my $logger = shift;
 	my $gitCmd = findBin("git",$logger);
@@ -196,7 +191,7 @@ sub dropStash($) {
 
 }
 
-sub stashAndReset {
+sub stashAndReset($) {
 
 	my $logger = shift;
 	my $gitCmd = findBin("git",$logger);
@@ -226,7 +221,7 @@ sub resetFromUpstream($) {
 
 }
 
-sub updateGitIgnore {
+sub updateGitIgnore($$$) {
 
 	my $path = shift;
 	# Maybe better to accept an array of values

+ 1 - 1
sg

@@ -185,7 +185,7 @@ if ( defined $args{'view'} ) {
 	chomp $name;
 	my $email = shellex("$gitCmd config --get user.email",$logger);
 	chomp $email;
-	print "Username: $name Email: $email\n";
+	print "-->Username: $name\n-->Email: $email\n";
 	print "On [branch] @ commit: $branch";
 	print "$refs\n";
 	my $swpWarning = "\t# Likely a Vi .swp file";