commit - adb27c97ca6881b235c352fdf9b9c723cf979564
commit + ecd8ede0168e19cdd076be1d3dc29b538db36ab5
blob - fb082187e33ef3726cfa060c46263e39c2672aea
blob + 6a06fb052ae8c67b865bdd47cb4b1102e20aefbc
--- bin/configNow.pl
+++ bin/configNow.pl
if ($shellConfig->repo_ready()) {
$shellConfig->write_config();
$shellConfig->repo_commit();
+} else {
+ print "Your ConfigNow git repo is not ready. Please review and commit the pending changes.\n"
+ . $shellConfig->repo_status()
+ . "\n";
}
-# get a list of commits - one line per commit with id
-#$r->run(qw(git log --oneline));
+print "\n" . $shellConfig->repo_log();
# Get list of files changed in a diff
#$r->run(qw(git diff 0cd562e --name-only));
-
blob - 6124eb6253aa013fd2c751461cfa9120cb95fb17
blob + ea451bb8329d73a762eacfaad39176dfe7b55f1d
--- lib/IRCNOW/ConfigNow/Module.pm
+++ lib/IRCNOW/ConfigNow/Module.pm
#
-sub list {
- my $self = shift;
- my $type = shift;
- my @list;
- for my $file (keys(%{$self->{files}})) {
- if (defined $type and exists $self->{files}->{type}) {
- next unless ($self->{files}->{$file}->{type} eq $type);
- }
- push @list, $file;
- }
- return @list;
-}
-
-#sub files {
+#sub list {
# my $self = shift;
-# return keys %{$self->{files}};
+# my $type = shift;
+# my @list;
+# for my $file (keys(%{$self->{files}})) {
+# if (defined $type and exists $self->{files}->{type}) {
+# next unless ($self->{files}->{$file}->{type} eq $type);
+# }
+# push @list, $file;
+# }
+# return @list;
#}
sub filenames {
my $type = shift;
my @params;
- # # Specified file doesn't exist in this module
- # return unless (
- # exists $self->{files}->{$file} and
- # # Shouldn't have $file without {$file}->{template}
- # #XXX should track down where it's being defined into existance
- # exists $self->{files}->{$file}->{template}
- # );
my $mod = $self->{lists}->{filenames}->{$filename};
# If we have a type value then limit output to type specified.
# Default to outputting all if not defined.
- #warn "Module::output() Filename: $filename \$type=$type - \$mod->{type} = ".$mod->{type};
+#warn "Module::output() Filename: $filename \$type=$type - \$mod->{type} = ".$mod->{type};
if (not defined $type or ($type eq $mod->{type})) {
for my $param ( @{$mod->{varlist}}) {
# Don't have needed param so return undef
blob - c3976502956c91a82a41b22ea25efc9f8d448282
blob + 8313c0351fb7e61e41288518e9203c12969db67b
--- lib/IRCNOW/ConfigNow.pm
+++ lib/IRCNOW/ConfigNow.pm
return keys %{$self->{lists}->{filenames}};
}
-sub list {
- my $self = shift;
- my $module = shift;
- my $type = shift;
- my @list;
-
- if (defined $module and exists $self->{modules}->{$module}) {
- @list = $self->{modules}->{$module}->list($type);
- } else {
- @list = keys %{$self->{modules}};
- }
- return @list;
-}
-
-#sub output {
-# my $self = shift;
-# my $filename = shift || die "!!!!!!!!!!! undef for filename:";
-# my $output = "";
-# # call each modules output()
-# for my $filename
-# for my $mod (keys %{$self->{modules}}) {
-# next unless exists $self->{modules}->{$mod}->{$file};
-# $output .= $self->{modules}->{$mod}->output($file) || "";
-# }
-# return $output;
-#}
-
-
sub mod_load {
my $self=shift;
my $modName=shift;
$filename = "$workDir/$filename";
print "Deleting $filename\n";
unlink $filename;
- # unlink $filename;
- #unlink $self->{modules}->{$module}->filename($file);
}
sub write_config {
return 1;
}
-
-# or my $module ($self->list()) {
-# #create the $type root entries. entries.
-# for my $file ($self->list($module,$type)) {
-#warn "write_config() \$type: $type, \$module: $module, \$file: $file\n";
-# $self->write_file($file);
-# }
-#warn "User Loop";
-# #Create entries for users where needed
-# }
-# return 1;
-#}
-
sub repo_ready {
my $self=shift;
my $r = $self->{repo};
return 1;
}
+sub repo_status {
+ my $self=shift;
+ my $r = $self->{repo};
+ my $workDir = $self->{vars}->{gitWorkDir};
+ # Check status of untracked files.
+ my $update=0; # Flag for changes to commit
+ my @output = $r->run(qw(status -su));
+ my $ret = "";
+ for my $line (@output) {
+ $ret .= "$line\n";
+ }
+ return $ret;
+}
+
+sub repo_log {
+ my $self=shift;
+ my $r = $self->{repo};
+ my $workDir = $self->{vars}->{gitWorkDir};
+ # Check status of untracked files.
+ my $update=0; # Flag for changes to commit
+ #my @output = $r->run(qw(log --oneline));
+ my @output = $r->run(qw(log));
+ my $ret = "";
+ for my $line (@output) {
+ $ret .= "$line\n";
+ }
+ return $ret;
+}
+
sub repo_connect {
my $self = shift;
my $config=$self->{vars};
return $self->{repo};
}
-sub repo_commit() {
+sub repo_commit {
my $self=shift;
my $r = $self->{repo};
my $workDir = $self->{vars}->{gitWorkDir};
my $update=0; # Flag for changes to commit
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 "$workDir/$1\n";
- $update = 1;
+ # if file is managed, add it to repo
+ if (exists $self->{lists}->{filenames}->{$1}) {
+ print "... adding $1\n";
+ $r->run('add', $1);
+ $update = 1;
+ } else {
+ print "... ignoring $1\n";
+ }
} elsif ($file =~ /^\s+M\s+/) {
$update = 1;
}