Done

On Fri, Dec 19, 2008 at 00:44, David Copeland <davetron5000@gmail.com> wrote:
That sounds good to me; thanks.  It's available here:
http://gist.github.com/37350

Thanks!

Dave

On Thu, Dec 18, 2008 at 5:59 AM, Oliver Burn <oliver@puppycrawl.com> wrote:
> I can include it in the contrib directory as is if you are happy
>
> David Copeland wrote:
>> I've got a pre-commit hook for git that prevents checkin if the code
>> in question doesn't pass your checks.  Normally, I'd just put it up on
>> github or google code, but since it's only one source file, I'm
>> wondering if there would be a way to include it with the "contrib"
>> stuff in the distro.
>>
>> Obviously, I'd want any/all to review it and give me feedback on
>> making sure the quality level is sufficient (which hopefully it is;
>> it's not terribly sophisticated).
>>
>> It's below if anyone wants to look at it.
>>
>> Dave
>>
>> #!/usr/bin/perl
>> #
>> # To use this you need:
>> # 1. checkstyle's jar file somewhere
>> # 2. a checkstyle XML check file somewhere
>> # 3. To configure git:
>> #   * git config --add checkstyle.jar <location of jar>
>> #   * git config --add checkstyle.checkfile <location of checkfile>
>> #   * git config --add java.command <path to java executale> [optional
>> #     defaults to assuming it's in your path]
>> # 4. Put this in your .git/hooks directory as pre-commit
>> #
>> # Now, when you commit, you will be disallowed from doing so
>> # until you pass your checkstyle checks.
>>
>> $command = "git-diff-index --cached HEAD 2>&1 | sed 's/^:.*   //' | uniq";
>> open (FILES,$command . "|") || die "Cannot run '$command': $!\n";
>>
>> $CONFIG_CHECK_FILE = "checkstyle.checkfile";
>> $CONFIG_JAR = "checkstyle.jar";
>> $CONFIG_JAVA = "java.command";
>>
>> $check_file = `git config --get $CONFIG_CHECK_FILE`;
>> $checkstyle_jar = `git config --get $CONFIG_JAR`;
>> $java_command = `git config --get $CONFIG_JAVA`;
>>
>> if (!$check_file || !$checkstyle_jar)
>> {
>>     die "You must configure checkstyle in your git config:\n"
>>     . "\t$CONFIG_CHECK_FILE - path to your checkstyle.xml file\n"
>>     . "\t$CONFIG_JAR - path to your checkstyle jar file\n"
>>     . "\t$CONFIG_JAVA - path to your java executable (optional)\n"
>>     ;
>> }
>>
>> $java_command = "java" if (!$java_command);
>>
>> chomp $check_file;
>> chomp $checkstyle_jar;
>> chomp $java_command;
>>
>> $command = "$java_command -jar $checkstyle_jar -c $check_file";
>>
>> @java_files = ();
>>
>> foreach (<FILES>)
>> {
>>     chomp;
>>     next if (!(/\.java$/));
>>     push @java_files,$_;
>>     $command .= " ";
>>     $command .= $_;
>> }
>> if ($#java_files >= 0)
>> {
>>     if (&run_and_log_system ($command))
>>     {
>>         print STDERR "Commit aborted.\n";
>>         exit -1;
>>     }
>> }
>>
>> exit 0;
>>
>> sub run_and_log_system
>> {
>>     ($cmd) = @_;
>>
>>     system $cmd;
>> }
>>
>> ------------------------------------------------------------------------------
>> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
>> The future of the web can't happen without you.  Join us at MIX09 to help
>> pave the way to the Next Web now. Learn more and register at
>> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
>> _______________________________________________
>> Checkstyle-devel mailing list
>> Checkstyle-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/checkstyle-devel
>>
>
> ------------------------------------------------------------------------------
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you.  Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> _______________________________________________
> Checkstyle-devel mailing list
> Checkstyle-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/checkstyle-devel
>

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Checkstyle-devel mailing list
Checkstyle-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/checkstyle-devel