Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
32 lines (28 loc) · 1.02 KB

File metadata and controls

executable file
·
32 lines (28 loc) · 1.02 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
#
# Setup Git pre-commit hook.
#
# stop when composer.json file is not found
if [[ ! -f "composer.json" ]]; then
echo "unable to locate composer.json file."
exit 1
fi
# determine the phpcs binary location
if [[ -f "vendor/bin/phpcs" ]]; then
phpcs_bin="./vendor/bin/phpcs"
elif [[ -n $COMPOSER_BIN_DIR && -f "$COMPOSER_BIN_DIR/phpcs" ]]; then
phpcs_bin="./$COMPOSER_BIN_DIR/phpcs"
elif [[ -n $COMPOSER_VENDOR_DIR && -f "$COMPOSER_VENDOR_DIR/bin/phpcs" ]]; then
phpcs_bin="./$COMPOSER_VENDOR_DIR/bin/phpcs"
else
echo "pre-commit hook: unable to locate phpcs binary file."
exit
fi
# create the pre-commit file or notify to add command if it already exists
pre_commit_file="$(git rev-parse --git-dir)/hooks/pre-commit"
if [[ ! -f "$pre_commit_file" ]]; then
echo -e "#!/bin/bash\nset -ex\n$phpcs_bin" > $pre_commit_file
chmod +x $pre_commit_file
elif ! grep -q "phpcs" $pre_commit_file; then
echo -e "hook file already exists: $pre_commit_file\n\nplease add the below command to your pre-commit file:\n\n$phpcs_bin"
fi
Morty Proxy This is a proxified and sanitized view of the page, visit original site.