Made committer details and time = author details and time
[git-darcs-import.git] / tests / haskell_policy.sh
blobeeb5d9ff1df85b808e40a0d40b317311ca739471
1 #!/usr/bin/env bash
3 RESULT=tmpfile
4 ROOT=..
5 ERRORSTATUS=0
7 # lookfor ( $1=what, $2=reason )
8 lookfor () {
9 rm -f "$RESULT"
10 darcs query manifest --repodir="$ROOT" | grep '\.l\?hs$' | while read f; do
11 grep -FHnwe "$1" "$ROOT/$f" | \
12 grep -v ":[0-9]\+:import " | grep -Fv "ratify $1: " >> "$RESULT"
13 done
14 if [ -s "$RESULT" ]; then
15 echo "Found the following unratified uses of $1:"
16 # ugly sed expresion to fix relative paths; think pretty cat
17 sed -e 's/[^:]*\/\.\///' "$RESULT"
18 echo "$2"
19 echo "Comment 'ratify $1: <why>' on the same line to allow it"
20 echo
21 ERRORSTATUS=1
23 rm -f "$RESULT"
27 lookfor readFile \
28 "readFile doesn't ensure the file is closed before it is deleted!"
30 lookfor hGetContents \
31 "hGetContents doesn't ensure the file is closed before it is deleted!"
33 lookfor HopefullyPrivate \
34 "HopefullyPrivate should not be imported anywhere but Hopefully. It's private!"
36 # look for tabs in haskell source
37 rm -f "$RESULT"
38 darcs query manifest --repodir="$ROOT" | grep '\.l\?hs$' | while read f; do
39 grep -FHnwe " " "$ROOT/$f" >> "$RESULT"
40 done
41 if [ -s "$RESULT" ]; then
42 echo "Found the following lines with unwanted tabs:"
43 # ugly sed expresion to fix relative paths; think pretty cat
44 sed -e 's/[^:]*\/\.\///' "$RESULT"
45 echo
46 ERRORSTATUS=1
48 rm -f "$RESULT"
50 exit "$ERRORSTATUS"