Remove arg n in plot_valse (deduce from X)
[valse.git] / hooks / pre-commit.bad
CommitLineData
7a56cc18
BA
1#!/bin/sh
2#
3# Hook used to indent all source files before commiting
4#
5
6# indent / format file by type
7indent() {
8 # getting against as the current commit
9 if git rev-parse --verify HEAD >/dev/null 2>&1
10 then
11 local against=HEAD
12 else
13 # Initial commit: diff against an empty tree object
14 local against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
15 fi
16
17 # loop on modified files
4464301b 18 git diff --cached --name-only $against | while read file;
7a56cc18
BA
19 do
20 local ext=$(expr "$file" : ".*\(\..*\)")
21 case $ext in
22 .R|.r)
23 __indent_R;
24 ;;
25 esac
26 done
27}
28
29# Indent the file with `indent' if this is a R file
30__indent_R() {
7a56cc18
BA
31 if test ! -f $file
32 then
33 return;
34 fi
35
36 echo "Indenting " $file
37 echo "library(formatR);formatR::tidy_source('$file',comment=TRUE,blank=TRUE,
f2041bb9 38 arrow=TRUE,brace.newline=TRUE,indent=2,width.cutoff=80,file='$file')" | R --slave
7a56cc18
BA
39 git add "$file"
40}
41
42indent