Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added (and enabled) a check-for-dos-endings pre commit hook

  • Loading branch information...
commit a27eecc2629048d25c1cec9a0a867999772e45ec 1 parent 80a5c99
joshuasilver joshuasilver authored
Showing with 27 additions and 1 deletion.
  1. +25 −0 check-for-dos-endings
  2. +2 −1  pre-commit
25 check-for-dos-endings
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+<?php
+$output = array();
+$return = 0;
+$exit_status = 0;
+
+// finds any DOS carriage returns, but ignores .git directory
+$cmd = "grep -PIlsr '\\r\\n' . | grep -v '.git'";
+// REGEX from: http://stackoverflow.com/questions/73833/how-do-you-search-for-files-containing-dos-line-endings-crlf-with-grep-under-li
+
+
+exec($cmd, $output, $return);
+if ($return != 1) {
+ echo "DOS line endings detected" . implode("\n", $output);
+ $exit_status = 1;
+ exit($exit_status);
+}
+
+/**
+bash script to fix dos files:
+WARNING: this overwrites files in place
+
+ for f in `grep -PIlsr '\r\n' . | grep -v '.git'`; do dos2unix ${f}; done
+
+**/
3  pre-commit
View
@@ -4,6 +4,7 @@
$commands = array(
'.git/hooks/run-php-lint',
'.git/hooks/check-whitespace',
+ '.git/hooks/check-for-dos-endings',
'.git/hooks/run-phpunit',
);
@@ -15,4 +16,4 @@ foreach ($commands as $command) {
echo implode("\n", $output) . "\n";
exit(1);
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.