Skip to content

Commit

Permalink
added pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ppekrol committed Nov 1, 2015
1 parent b19bf61 commit b63d120
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 48 deletions.
62 changes: 31 additions & 31 deletions .gitattributes
Expand Up @@ -2,38 +2,38 @@
* text=auto

# Custom for Visual Studio
*.cs text diff=csharp eol=crlf filter=raven-spacify
*.cs text diff=csharp eol=crlf
*.sln text merge=union eol=crlf
*.csproj text merge=union eol=crlf filter=raven-spacify
*.vbproj text merge=union filter=raven-spacify
*.fsproj text merge=union filter=raven-spacify
*.dbproj text merge=union filter=raven-spacify
*.ascx text eol=crlf filter=raven-spacify
*.xaml text eol=crlf filter=raven-spacify
*.cmd text eol=crlf filter=raven-spacify
*.ps1 text eol=crlf filter=raven-spacify
*.coffee text eol=crlf filter=raven-spacify
*.config text eol=crlf filter=raven-spacify
*.css text eol=crlf filter=raven-spacify
*.nuspec text eol=crlf filter=raven-spacify
*.scss text eol=crlf filter=raven-spacify
*.cshtml text eol=crlf filter=raven-spacify
*.htm text eol=crlf filter=raven-spacify
*.html text eol=crlf filter=raven-spacify
*.js text eol=crlf filter=raven-spacify
*.ts text eol=crlf filter=raven-spacify
*.msbuild text eol=crlf filter=raven-spacify
*.resx text merge=union filter=raven-spacify
*.ruleset text filter=raven-spacify
*.Stylecop text filter=raven-spacify
*.targets text eol=crlf filter=raven-spacify
*.tt text filter=raven-spacify
*.txt text eol=crlf filter=raven-spacify
*.vb text eol=crlf filter=raven-spacify
*.vbhtml text eol=crlf filter=raven-spacify
*.xml text eol=crlf filter=raven-spacify
*.xunit text eol=crlf filter=raven-spacify
*.java text eol=lf filter=raven-spacify
*.csproj text merge=union eol=crlf
*.vbproj text merge=union
*.fsproj text merge=union
*.dbproj text merge=union
*.ascx text eol=crlf
*.xaml text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.coffee text eol=crlf
*.config text eol=crlf
*.css text eol=crlf
*.nuspec text eol=crlf
*.scss text eol=crlf
*.cshtml text eol=crlf
*.htm text eol=crlf
*.html text eol=crlf
*.js text eol=crlf
*.ts text eol=crlf
*.msbuild text eol=crlf
*.resx text merge=union
*.ruleset text
*.Stylecop text
*.targets text eol=crlf
*.tt text
*.txt text eol=crlf
*.vb text eol=crlf
*.vbhtml text eol=crlf
*.xml text eol=crlf
*.xunit text eol=crlf
*.java text eol=lf

*.bmp binary
*.gif binary
Expand Down
21 changes: 21 additions & 0 deletions Tools/Git/pre-commit
@@ -0,0 +1,21 @@
#!/bin/sh

if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

files=`git diff-index --name-only $against | # Find all changed files
egrep '\.cs$|\.csproj$|\.vbproj$|\.fsproj$|\.dbproj$|\.ascx$|\.xaml$|\.cmd$|\.ps1$|\.coffee$|\.config$|\.css$|\.nuspec$|\.scss$|\.cshtml$|\.htm$|\.html$|\.js$|\.ts$|\.msbuild$|\.resx$|\.ruleset$|\.Stylecop$|\.targets$|\.tt$|\.txt$|\.vb$|\.vbhtml$|\.xml$|\.xunit$|\.java$|\.less$' |
uniq` # Remove duplicate files

# Find files with trailing whitespace
for FILE in $files ; do
echo "Fixing whitespace in $FILE"
TMP="$FILE.tmp"
expand --tabs=4 --initial "$FILE" > TMP
mv TMP "$FILE"
git add "$FILE"
done
18 changes: 1 addition & 17 deletions git_setup.ps1
@@ -1,17 +1 @@
$gitPath = "C:\Program Files\Git\bin\git.exe";
If (Test-Path $gitPath) {
} else {
$gitPath = "C:\Program Files (x86)\Git\bin\git.exe";
}

$filterToInsert = 'expand --tabs=4 --initial'

&$gitPath config --global filter.raven-spacify.clean $filterToInsert

$filterThatWasInserted = &$gitPath config --global --get filter.raven-spacify.clean

if ($filterToInsert -eq $filterThatWasInserted) {
Write-Host 'Git setup successful. Filter added.' -foregroundcolor "green"
} else {
Write-Host 'Git setup failed. Filter was not added.' -foregroundcolor "red"
}
Copy-Item Tools\Git\pre-commit .git\hooks\pre-commit

0 comments on commit b63d120

Please sign in to comment.