Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
sneltved
openairinterface5G
Commits
fa9b91ad
Commit
fa9b91ad
authored
Feb 24, 2017
by
Cedric Roux
Browse files
Merge remote-tracking branch 'origin/pre-commit-hook' into develop_integration_w08
parents
2c238010
068ce4ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
pre-commit
0 → 100644
View file @
fa9b91ad
#!/bin/bash
# Installation:
# cp pre-commit .git/hooks
# chmod +x .git/hooks/pre-commit
OPTIONS
=
"--convert-tabs --indent=spaces=2 --indent-switches --indent-col1-comments --break-blocks --delete-empty-lines --align-pointer=name --keep-one-line-blocks --keep-one-line-statements --lineend=linux"
RETURN
=
0
ASTYLE
=
$(
which astyle
)
if
[
$?
-ne
0
]
;
then
echo
"[!] astyle not installed. Unable to check source file format policy."
>
&2
exit
1
fi
FILES
=
`
git diff
--cached
--name-only
--diff-filter
=
ACMR |
grep
-E
"
\.
(c|cpp|h)$"
`
for
FILE
in
$FILES
;
do
$ASTYLE
$OPTIONS
<
$FILE
| cmp
-s
$FILE
-
if
[
$?
-ne
0
]
;
then
echo
"[!]
$FILE
does not respect the agreed coding style."
>
&2
RETURN
=
1
fi
done
if
[
$RETURN
-eq
1
]
;
then
echo
""
>
&2
echo
"Make sure you have run astyle with the following options:"
>
&2
echo
$OPTIONS
>
&2
fi
exit
$RETURN
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment