Commit Diff


commit - 88da003bb57c4fe23764101ecb9d776106a5c32b
commit + 7b334ef113973160fc72ab52809a495b42ae3816
blob - 3206ccebed6c8fdfac26de40021b1bb7e45a7225
blob + 303b7c6a83de68f58b2afb8405acb8104d405a6a
--- bin/configNow.pl
+++ bin/configNow.pl
@@ -12,15 +12,17 @@ use Git::Repository::Command;
 
 my $shellname = shift || 'bnsnet';
 my $username = shift || 'izzyb';
-
+my $domain = 'user.planetofnix.com';
 my %config=(
 	type=>'shell',
 	shellname => $shellname,
 	username => $username,
+	gitAuthor => $shellname,
+	gitEmail => $shellname . "@" . $domain,
 	configNow => './configNow',
 	ipv4 => '38.87.162.191',
 	ipv6 => '2602:fccf:1:1191::',
-	domain => 'user.planetofnix.com',
+	domain => $domain,
 );
 my $shellConfig = new IRCNOW::ConfigNow( %config );
 
@@ -37,12 +39,37 @@ for my $module ($shellConfig->list()) {
 	}
 }
 
-my $r = Git::Repository->new(work_tree => $config{configNow});
+# Initialize the config repo if it hasn't been created yet.
+if (not -d $config{configNow}."/.git") {
+	Git::Repository->run(init => $config{configNow});
+}
 
-my $cmd = Git::Repository::Command->new($r, [qw(status)]);
-$cmd->close();
+# Check status of untracked files.
+my $update=0; # Flag for changes to commit
+my $r = Git::Repository->new(
+	work_tree => $config{configNow},
+	{
+		env => {
+			GIT_COMMITTER_EMAIL => $config{gitEmail},
+			GIT_COMMITTER_NAME => $config{gitAuthor},
+		}
+	}
+);
+my @output = $r->run(qw(status -su));
+for my $file (@output) {
+	# XXX need to verify the file is managed
+	# XXX what should happen with unmanaged files
+	if ($file =~ /^\?\?\s+(.*)/) {
+		$r->run('add', $1);
+		print $config{configNow}."/$1\n";
+		$update = 1; 
+	} elsif ($file =~ /^\s+M\s+/) {
+		$update = 1;
+	}
+}
 
-print $cmd->exit();
+if ($update) {
+	$r->run('commit', '-a', '-m', 'configNow Auto Commit');
+}
 
 
-