[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Debian JP master SVN www commits (rev.478)
=======================================================
Repository: /org/svn.debian.or.jp/repos
Revision: 478
Commiter: kmuto
Date: 2007-10-15 23:18:44 +0900 (月, 15 10月 2007)
=======================================================
Log:
lazy validator for blosxom/tt2 pages
=======================================================
Changed:
A www/trunk/progs/quick-validate
Added: www/trunk/progs/quick-validate
===================================================================
--- www/trunk/progs/quick-validate (rev 0)
+++ www/trunk/progs/quick-validate 2007-10-15 14:18:44 UTC (rev 478)
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -w
+# quick validator as Subversion pre-commit hook
+# Copyright 2007 Kenshi Muto <kmuto@debian.org>
+
+use strict;
+use Text::Iconv;
+
+exit(0) if (@ARGV < 2);
+
+my(@targets) = qw(MirrorsJP.list blosxom/ include/ src/);
+my($svnlook) = "/usr/bin/svnlook";
+
+my($repos) = $ARGV[0];
+my($txn) = $ARGV[1];
+my(@files);
+my($status) = "";
+my($converter_euc) = Text::Iconv->new("EUC-JP", "EUC-JP");
+
+open(P, "$svnlook changed $repos -t $txn |");
+while(<P>) {
+ if (/^U/ || /^A/) {
+ # update or new
+ chomp;
+ my($flag, $file) = split(/\s+/, $_, 2);
+ next if ($file =~ /\/$/); # directory
+ my($go) = 0;
+ foreach my $t (@targets) {
+ if ($file =~ /^$t/) {
+ $go = 1;
+ last;
+ }
+ }
+ next if ($go == 0);
+
+ push(@files, $file);
+ }
+}
+close(P);
+
+foreach my $file (@files) {
+ open(P, "$svnlook cat $repos $file -t $txn |");
+ my($line) = 1;
+ while (<P>) {
+
+ if ($status !~ /:encoding:/) {
+ $converter_euc->convert($_);
+ if (!defined($converter_euc->retval)) {
+ print STDERR "$file (-): The encoding must be EUC-JP.\n";
+ $status .= ":encoding:" if ($status !~ /:encoding:/);
+ }
+ }
+
+ if ($file =~ /^blosxom\/.*\.d$/) {
+ # Check blosxom articles
+ if ($line == 2 && !/^\s*$/) {
+ print STDERR "$file ($line): Insert a newline at line 2.\n";
+ $status .= ":newline:";
+ }
+ if (/\[%/ || /%\]/) {
+ print STDERR "$file ($line): You can't use TT tag [% %] in a blog article.\n";
+ $status .= ":TT:" if ($status !~ /:TT:/);
+ }
+ if (/\&/g) {
+ my($post) = $';
+ if ($post !~ /^\#\d+;/ && $post !~ /^[a-z0-9]+;/ && $post !~ /^amp;/) {
+ print STDERR "$file ($line): & should be replaced with '&' entity.\n";
+ $status .= ":amp:" if ($status !~ /:amp:/);
+ }
+
+ }
+ }
+
+ $line++;
+ }
+ close(P);
+}
+
+($status eq "") ? exit(0) : exit(1);
Property changes on: www/trunk/progs/quick-validate
___________________________________________________________________
Name: svn:executable
+ *