3 GNATROOT
=/opt
/gnat
/2007
5 PATH
=$GNATROOT/bin
:$HOME/bin
:$PATH
20 REPOSIT_NAME
=`basename $PWD`
22 [ "$REPOSIT_NAME" == "" ] && echo No repository found
&& exit 1;
24 # Set Style_Checker options
26 OWEB
="-H -cP -cY -l256"
28 # The copyright pattern to check
31 # Pathnames matching the regexp will be excluded from the test
34 case "$REPOSIT_NAME" in
35 v2p
) SC_OPTS
="-ign out -ign tmplt -ign sed -ign txt \
36 -lang Ada -d -cp -cy -sp -gnat05 -lang TXML $OWEB -lang Script -H \
37 -lang XML $OWEB -lang HTML $OWEB -lang XSD $OWEB -lang CSS $OWEB"
39 *) SC_OPTS
="-ign out -ign tmplt -ign sed -ign txt \
40 -lang Ada -H -cP -cY -sp -gnat05 -lang TXML $OWEB \
41 -lang XML $OWEB -lang HTML $OWEB -lang XSD $OWEB -lang CSS $OWEB"
45 # Source .git-pre-commit hook for user's defined rules
47 [ -f $HOME/.git-pre-commit
] && source $HOME/.git-pre-commit
$REPOSIT_NAME
54 mode
=$
(echo $5 | cut
-c1)
56 # Check if it is a file to ignore
58 if [[ -n "$EXCLUDE" && `echo "$6" | grep --regexp="$EXCLUDE"` ]]; then
62 # skip deleted/renamed files
64 if [[ "$mode" = "D" ||
"$mode" = "R" ]]; then
65 echo $6 >> $REP/.files.removed
69 git show
$id > $REP/$file
71 # If the MANIFEST keep it around
73 if [[ "$6" = "$MANIFEST" ]]; then
74 cp $REP/$file $REP/.manifest
77 # If a new file, record it
79 if [[ "$mode" == "A" ]]; then
80 echo $6 >> $REP/.files.added
83 ( cd $REP; style_checker
$SC_OPTS -n "$6" "$file"; )
90 # Get files to be commited
91 # <N1> <N2> <Id-OLD> <Id-NEW> <status> <Filename>
92 git diff-index
-M --cached HEAD
> $REP/.files
99 # Check for MANIFEST if needed
101 if [[ -n "$MANIFEST" && -f $REP/.files.added
]]; then
102 if [[ ! -f $REP/.manifest
]]; then
104 echo Files added
, but
$MANIFEST not updated
, consider adding
:
105 git
diff --cached --name-only --diff-filter=A
110 grep --quiet $fadded $REP/.manifest
111 if [[ $?
= 1 ]]; then
112 echo File
$fadded added but missing
in $MANIFEST
115 done < $REP/.files.added
119 if [[ -n "$MANIFEST" && -f $REP/.files.removed
]]; then
120 if [[ ! -f $REP/.manifest
]]; then
122 echo Files removed
, but
$MANIFEST not updated
, condider removing
:
123 git
diff --cached --name-only --diff-filter=D
128 grep --quiet $fremoved $REP/.manifest
129 if [[ $?
= 0 ]]; then
130 echo File
$fremoved removed but still
in $MANIFEST
133 done < $REP/.files.removed