]> gitweb @ CieloNegro.org - sugar.git/commitdiff
Initial commit: make lint prints only missing files.
authorPHO <pho@cielonegro.org>
Fri, 5 Dec 2008 10:12:26 +0000 (19:12 +0900)
committerPHO <pho@cielonegro.org>
Fri, 5 Dec 2008 10:12:26 +0000 (19:12 +0900)
GNUmakefile [new file with mode: 0644]
NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE [new file with mode: 0644]
tools/lint-dotfiles.pl [new file with mode: 0644]

diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644 (file)
index 0000000..9bb9a2f
--- /dev/null
@@ -0,0 +1,4 @@
+lint:
+       perl ./tools/lint-dotfiles.pl
+
+.PHONY: lint
\ No newline at end of file
diff --git a/NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE b/NEVER_PUT_ANYTHING_CONFIDENTIAL_HERE
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tools/lint-dotfiles.pl b/tools/lint-dotfiles.pl
new file mode 100644 (file)
index 0000000..852791b
--- /dev/null
@@ -0,0 +1,119 @@
+use strict;
+use warnings;
+use Smart::Comments;
+use List::MoreUtils qw(any);
+use File::Spec;
+
+my @RE_IGNORED = map {
+    s/\./\\./g;
+    s/\+/\\+/g;
+
+    s/\?/.?/g;
+    s/\*/.*?/g;
+
+    qr/^$_$/;
+  }
+  grep {length}
+  map  {tr/\n//d; $_}
+  <DATA>;
+
+my @CURRENT = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./});
+
+sub find {
+    my $base = shift;
+    my $dir  = shift || '.';
+    my $sel  = shift || sub {1};
+
+    my $dirpath = File::Spec->catfile($base, $dir);
+    opendir my $dh, $dirpath or die "opendir: $dirpath: $!";
+
+    my @d;
+    while (my $name = readdir $dh) {
+        next if $name =~ /^\.\.?$/;
+        next if !$sel->($name);
+
+        my $abs = File::Spec->rel2abs($name, $dirpath);
+        my $rel = File::Spec->abs2rel($abs, $base);
+
+        next if any { $rel =~ m/$_/ } @RE_IGNORED;
+
+        if (-d $abs) {
+            push @d, find($base, $rel);
+        }
+        else {
+            push @d, $rel;
+        }
+    }
+    @d;
+}
+
+foreach my $file (@CURRENT) {
+    # Is it in the repository?
+    if (-e $file) {
+
+    }
+    else {
+        print "? $file\n";
+    }
+}
+
+__DATA__
+*~
+.*cache*
+.*history*
+.CFUserTextEncoding
+.DS_Store
+.ICEauthority
+.MacOSX
+.Trash
+.Xauthority
+.cabal
+.cpan
+.dbus
+.dvdcss
+.easytag
+.elisp
+.esd_auth
+.emacs.d
+.eshell
+.firefox
+.fontconfig*
+.fonts
+.gconf*
+.gimp*
+.glimpse*
+.gnome2*
+.gnucash
+.gnupg
+.gstreamer-0.10
+.htpasswd
+.ido.last*
+.jungledisk*
+.kde
+.localized
+.mozilla
+.mpd
+.mplayer
+.nautilus
+.navi2ch
+.nh-todo
+.pan
+.projects.ede
+.qt
+.recently-used*
+.rnd
+.s9x
+.scribus
+.skk-*
+.snes*
+.ssh
+.thumbnails
+.tome
+.trackballs
+.uim.d
+.unison
+.viminfo
+.w3m
+.xchat2*
+.zcomp*
+.zfunc