55# exit with non-zero status after issuing an appropriate message if
66# it wants to stop the commit.
77#
8- # To enable this hook, rename this file to "pre-commit" within .git\hooks
9- # or run git config core.hooksPath .githooks
8+ # To enable this hook, rename this file to "pre-commit".
109#
1110# Exit on error
12- # set -e
11+ # set -e
1312
1413project_dir=$( git rev-parse --show-toplevel)
1514
15+ psrfix () {
16+ command -v php-cs-fixer > /dev/null || return
17+ $( command -v php-cs-fixer) fix $project_dir /packages/web --rules=@PSR2
18+ git add $project_dir /packages/web
19+ }
20+
1621updateLanguage () {
1722 command -v xgettext > /dev/null || return
1823 command -v msgcat > /dev/null || return
@@ -23,10 +28,10 @@ updateLanguage() {
2328 msgmerge --update --backup=none $PO_FILE $project_dir /packages/web/management/languages/messages.pot 2> /dev/null > /dev/null
2429 msgcat --sort-output -o $PO_FILE $PO_FILE
2530 done
26- git add " $project_dir /packages/web/management/languages"
2731}
2832
2933updateLanguage
34+ # psrfix
3035
3136# Get the current branch name
3237gitbranch=$( git branch --show-current)
@@ -44,7 +49,7 @@ branchon=$(echo ${gitbranch} | awk -F'-' '{print $1}')
4449branchend=$( echo ${gitbranch} | awk -F' -' ' {print $2}' )
4550
4651# Define the path to the system file
47- system_file=" $( git rev-parse --show-toplevel ) /packages/web/lib/fog/system.class.php"
52+ system_file=" $project_dir /packages/web/lib/fog/system.class.php"
4853
4954current_version=$( grep " define('FOG_VERSION'" $system_file | sed " s/.*FOG_VERSION', '\([^']*\)');/\1/" )
5055
@@ -61,12 +66,12 @@ case $branchon in
6166 channel=" Patches"
6267 ;;
6368 stable)
64- # For stable, don't increment version, use what is being pulled from dev-branch
69+ # Describe the tag and append the commit count correctly
6570 tagversion=$( git describe --tags ${gitcom} )
6671 baseversion=${tagversion% .* } # Retain everything before the last segment
6772 lastrevision=${tagversion##* .} # Extracts the last segment
68- gitcount=$( git rev-list master..dev-branch --count) # get the gitcount from dev-branch instead
6973 trunkversion=" ${baseversion} .${gitcount} "
74+ gitcount=$( git rev-list master..dev-branch --count) # Get the gitcount from dev-branch instead
7075 channel=" Patches"
7176 ;;
7277 working)
@@ -78,7 +83,7 @@ case $branchon in
7883 rc)
7984 channel=" Release Candidate"
8085 version_prefix=" ${branchend} .0-RC"
81- if [[ $current_version =~ $ version_prefix -([0-9]+) ]]; then
86+ if [[ $current_version =~ " ${ version_prefix} -([0-9]+)" ]]; then
8287 last_rc_version=${BASH_REMATCH[1]}
8388 next_rc_version=$(( last_rc_version + 1 ))
8489 else
0 commit comments