X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=hooks%2Fpre-commit;fp=hooks%2Fpre-commit;h=0000000000000000000000000000000000000000;hb=1b698c1619dbcf5b3a0608dc894d249945d2bce3;hp=bf5d7357a0d7a5d4c222d2a559b399d1baace18a;hpb=f7e157cdbcf2d60224c2d6773da9c698174e9aee;p=valse.git diff --git a/hooks/pre-commit b/hooks/pre-commit deleted file mode 100755 index bf5d735..0000000 --- a/hooks/pre-commit +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# Hook used to indent all source files before commiting -# - -# indent / format file by type -indent() { - # getting against as the current commit - if git rev-parse --verify HEAD >/dev/null 2>&1 - then - local against=HEAD - else - # Initial commit: diff against an empty tree object - local against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 - fi - - # loop on modified files - git diff --cached --name-only $against | while read file; - do - local ext=$(expr "$file" : ".*\(\..*\)") - case $ext in - .R|.r) - __indent_R; - ;; - esac - done -} - -# Indent the file with `indent' if this is a R file -__indent_R() { - if test ! -f $file - then - return; - fi - - echo "Indenting " $file - echo "library(formatR);formatR::tidy_source('$file',comment=TRUE,blank=TRUE, - arrow=TRUE,brace.newline=TRUE,indent=2,width.cutoff=80,file='$file')" | R --slave - git add "$file" -} - -indent