Permalink
Browse files

Add missing

  • Loading branch information...
1 parent b42bf35 commit 4d748bf28afdad269c8cecaab8087368d39ab7ce @holdenk committed Nov 22, 2012
Showing with 89 additions and 2 deletions.
  1. +7 −2 main.pl
  2. +82 −0 shared_fix.pl
  3. 0 t/thorough.t
View
@@ -64,13 +64,18 @@ sub handle_possible_repo {
sub setup_output {
my $hosts;
open ($hosts, "hosts.txt");
+ print "Clean up old distro tarball\n";
+ `rm magic.tar.bz2; rm magic.tar`;
+ print "Making new distro tarball\n";
+ `tar -cf ./magic.tar ./; tar -Af ./magic.tar ../settings.yml`;
+ print "Compressing\n";
+ `bzip2 magic.tar`;
while (my $hostline = <$hosts>) {
my @murh = split(/\:/,$hostline);
my $hostname = $murh[0];
my $pwd = $murh[1];
- `rm magic.tar;tar -cfa ./magic.tar.bz2 ./; tar -Aa ./magic.tar.bz2 ../`;
print "Updating host $hostname\n";
- `scp magic.tar $hostname:~/`;
+ `scp magic.tar.bz2 $hostname:~/`;
my ($child_out,$child_in);
open2($child_in, $child_out, "ssh -t -t $hostname");
#hack
View
@@ -0,0 +1,82 @@
+sub handle_files {
+ my @files = @_;
+ my @handlers = (handle_group("Fixing typos in README",qr/\/README(\.txt|\.rtf|\.md|\.pm|\.m\w+)$/,\&check_common,\&fix_text),
+ handle_group("Fixing old PHP calls",qr/\.php$/,\&check_php,\&fix_php),
+ handle_group("Updating shell scripts",qr/\/\w(\.sh|\.bash|)$/,\&check_shell,\&fix_shell),
+ handle_group("Fixing deprecated django",qr/\.py$/,\&check_py,\&fix_py),
+ handle_group("Fixing c",qr/\.c$/,\&check_cpp,\&fix_cpp),
+ handle_group("Fixing c++",qr/\.cpp$/,\&check_cpp,\&fix_cpp),
+ handle_group("Fixing scala",qr/\.scala$/,\&check_scala,\&fix_scala),
+ handle_group_cmd("Fixing go formatting",qr/\.go$/,\&check_go,\&fix_go));
+ my @handler_names = ("typos","deprecated php","portable shell","deprecated django","go fix");
+ my $i = 0;
+ my $short_msg = "Fix ";
+ my @changes = ();
+ while ($i < $#handlers+1) {
+ my $r = $handlers[$i](@files);
+ if ($r) {
+ push @changes, $handler_names[$i];
+ }
+ $i++;
+ }
+ return @changes;
+}
+sub handle_group {
+ my $git_message = shift @_;
+ my $gate_regex = shift @_;
+ my $gate_function = shift @_;
+ my $fix_function = shift @_;
+ return sub {
+ my $changes = 0;
+ my @files = @_;
+ foreach my $file (@files) {
+ if ($file !~ /\/\.git\// && $file =~ $gate_regex) {
+ open (my $in, "<", "$file") or die "Unable to open $file";
+ my $t = do { local $/ = <$in> };
+ close($in);
+ #Is there a spelling mistake?
+ if ($gate_function->($file, $t)) {
+ open (my $out, ">", "$file") or die "Unable to open $file";
+ print $out $fix_function->($file, $t);
+ close ($out);
+ }
+ }
+ }
+ #Determine if we have made any difference
+ `cd foo/*;git diff --exit-code`;
+ if ($? != 0) {
+ #Yup
+ `cd foo/*;git commit -a -m \"$git_message\";`;
+ return 1;
+ }
+ #Nope no changes
+ return 0;
+ }
+}
+
+sub handle_group_cmd {
+ my $git_message = shift @_;
+ my $gate_regex = shift @_;
+ my $gate_function = shift @_;
+ my $fix_function = shift @_;
+ return sub {
+ my $changes = 0;
+ my @files = @_;
+ foreach my $file (@files) {
+ if ($file !~ /\/\.git\// && $file =~ $gate_regex) {
+ $fix_function->($file);
+ }
+ }
+ #Determine if we have made any difference
+ `cd foo/*;git diff --exit-code`;
+ if ($? != 0) {
+ #Yup
+ `cd foo/*;git commit -a -m \"$git_message\";`;
+ return 1;
+ }
+ #Nope no changes
+ return 0;
+ }
+}
+
+1;
View
No changes.

0 comments on commit 4d748bf

Please sign in to comment.