]> git.xonotic.org Git - xonotic/xonotic.git/blob - check-gitattributes.sh
Merge branch 'Mario/win64_v2' into 'master'
[xonotic/xonotic.git] / check-gitattributes.sh
1 #!/bin/bash
2
3 exec 3<&0
4
5 ISANYTHING=" -crlf"
6 ISBINARY=" -diff -crlf"
7 ISTEXT=" crlf=input"
8
9 LF="
10 "
11 eol=`cat .gitattributes`
12 find . -name .git -prune -o -name xonotic-nexcompat.pk3dir -prune -o \( -type f -print \) | {
13         unseen=`echo "$eol" | cut -d ' ' -f 1 | grep .`
14         neweol=
15         while IFS= read -r LINE; do
16                 nam=${LINE##*/}
17                 case "$nam" in
18                         *.txt.*)
19                                 nam="*.txt.*"
20                                 ;;
21                         *.db.*)
22                                 nam="*.db.*"
23                                 ;;
24                         *.*)
25                                 nam="*.${nam##*.}"
26                                 ;;
27                 esac
28                 t=`file -b --mime-type "$LINE"`
29                 case "$t" in
30                         application/x-symlink)
31                                 continue
32                                 ;;
33                         text/*|application/xml|application/x-ruby)
34                                 t=true
35                                 ;;
36                         *)
37                                 t=false
38                                 ;;
39                 esac
40                 unseen=`{ echo "$nam"; echo "$nam"; echo "$unseen"; } | sort | uniq -u`
41                 case "$LF$eol$LF$neweol$LF" in
42                         *$LF$nam$ISANYTHING*$LF*)
43                                 # ignore and treat as binary
44                                 ;;
45                         *$LF$nam$ISBINARY*$LF*)
46                                 # should be binary
47                                 if $t; then
48                                         echo "WARNING: file $LINE is text, should be binary"
49                                 fi
50                                 ;;
51                         *$LF$nam$ISTEXT*$LF*)
52                                 # should be text
53                                 if ! $t; then
54                                         echo "WARNING: file $LINE is binary, should be text"
55                                 fi
56                                 ;;
57                         *)
58                                 # unknown
59                                 if $t; then
60                                         echo "NOTE: added new type TEXT for $LINE"
61                                         neweol="$neweol$LF$nam$ISTEXT"
62                                 else
63                                         echo "NOTE: added new type BINARY for $LINE"
64                                         neweol="$neweol$LF$nam$ISBINARY"
65                                 fi
66                                 ;;
67                 esac
68         done
69         echo "$neweol"
70         echo "not seen: $unseen"
71 }