Skip to content

Commit b884cbf

Browse files
committed
Testing again
1 parent 9e92ea1 commit b884cbf

File tree

2 files changed

+29
-33
lines changed

2 files changed

+29
-33
lines changed

.githooks/pre-commit

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1-
#!/usr/bin/sh
1+
#!/usr/bin/env sh
22
#
3-
# An example hook script to verify what is about to be committed.
4-
# Called by "git commit" with no arguments. The hook should
5-
# exit with non-zero status after issuing an appropriate message if
6-
# it wants to stop the commit.
7-
#
8-
# To enable this hook, rename this file to "pre-commit".
9-
#
10-
# Exit on error
3+
# Exit on error? You had this commented out; leaving it as-is.
114
# set -e
125

136
project_dir=$(git rev-parse --show-toplevel)
147

158
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
9+
command -v php-cs-fixer >/dev/null 2>&1 || return
10+
"$(command -v php-cs-fixer)" fix "$project_dir/packages/web" --rules=@PSR2
11+
git add "$project_dir/packages/web"
1912
}
2013

2114
updateLanguage() {
22-
command -v xgettext >/dev/null || return
23-
command -v msgcat >/dev/null || return
24-
command -v msgmerge >/dev/null || return
25-
xgettext --language=PHP --from-code=UTF-8 --output="$project_dir/packages/web/management/languages/messages.pot" --omit-header --no-location $(find $project_dir/packages/web/ -name "*.php")
15+
command -v xgettext >/dev/null 2>&1 || return
16+
command -v msgcat >/dev/null 2>&1 || return
17+
command -v msgmerge >/dev/null 2>&1 || return
18+
xgettext --language=PHP --from-code=UTF-8 --output="$project_dir/packages/web/management/languages/messages.pot" --omit-header --no-location $(find "$project_dir/packages/web/" -name "*.php")
2619
msgcat --sort-output -o "$project_dir/packages/web/management/languages/messages.pot" "$project_dir/packages/web/management/languages/messages.pot"
27-
for PO_FILE in $(find $project_dir/packages/web/management/languages/ -type f -name *.po); do
28-
msgmerge --update --backup=none $PO_FILE $project_dir/packages/web/management/languages/messages.pot 2>/dev/null >/dev/null
29-
msgcat --sort-output -o $PO_FILE $PO_FILE
20+
for PO_FILE in $(find "$project_dir/packages/web/management/languages/" -type f -name "*.po"); do
21+
msgmerge --update --backup=none "$PO_FILE" "$project_dir/packages/web/management/languages/messages.pot" 2>/dev/null >/dev/null
22+
msgcat --sort-output -o "$PO_FILE" "$PO_FILE"
3023
done
3124
}
3225

@@ -39,35 +32,35 @@ gitbranch=$(git branch --show-current)
3932
# Get the latest tag commit
4033
gitcom=$(git rev-list --tags --no-walk --max-count=1)
4134

42-
# Count commits from the last tag to HEAD
35+
# Count commits from the last tag to HEAD (your original logic)
4336
gitcount=$(git rev-list master..HEAD --count)
4437

4538
# Extract the first part of the branch name
46-
branchon=$(echo ${gitbranch} | awk -F'-' '{print $1}')
39+
branchon=$(echo "$gitbranch" | awk -F'-' '{print $1}')
4740

4841
# Extract the second part of the branch name
49-
branchend=$(echo ${gitbranch} | awk -F'-' '{print $2}')
42+
branchend=$(echo "$gitbranch" | awk -F'-' '{print $2}')
5043

5144
# Define the path to the system file
5245
system_file="$project_dir/packages/web/lib/fog/system.class.php"
5346

54-
current_version=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
47+
current_version=$(grep "define('FOG_VERSION'" "$system_file" | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
5548

5649
verbegin=""
5750
channel=""
5851

59-
case $branchon in
52+
case "$branchon" in
6053
dev)
6154
# Describe the tag and append the commit count correctly
62-
tagversion=$(git describe --tags ${gitcom})
55+
tagversion=$(git describe --tags "$gitcom")
6356
baseversion=${tagversion%.*} # Retain everything before the last segment
6457
lastrevision=${tagversion##*.} # Extracts the last segment
6558
trunkversion="${baseversion}.${gitcount}"
6659
channel="Patches"
6760
;;
6861
stable)
6962
# Describe the tag and append the commit count correctly
70-
tagversion=$(git describe --tags ${gitcom})
63+
tagversion=$(git describe --tags "$gitcom")
7164
baseversion=${tagversion%.*} # Retain everything before the last segment
7265
lastrevision=${tagversion##*.} # Extracts the last segment
7366
trunkversion="${baseversion}.${gitcount}"
@@ -83,9 +76,12 @@ case $branchon in
8376
rc)
8477
channel="Release Candidate"
8578
version_prefix="${branchend}.0-RC"
86-
if [[ $current_version =~ ${version_prefix}-([0-9]+) ]]; then
87-
last_rc_version=${BASH_REMATCH[1]}
79+
# POSIX replacement for: if [[ $current_version =~ ${version_prefix}-([0-9]+) ]]
80+
n=$(printf '%s\n' "$current_version" | sed -n "s/^${version_prefix}-\([0-9][0-9]*\)\$/\1/p")
81+
if [ -n "$n" ]; then
82+
last_rc_version=$n
8883
next_rc_version=$((last_rc_version + 1))
84+
trunkversion="${version_prefix}-${next_rc_version}"
8985
else
9086
trunkversion="${version_prefix}-1"
9187
fi
@@ -97,10 +93,10 @@ case $branchon in
9793
;;
9894
esac
9995

100-
10196
# Update the version and channel in the system file
102-
sed -i "s/define('FOG_VERSION',.*);/define('FOG_VERSION', '$trunkversion');/g" $system_file
103-
sed -i "s/define('FOG_CHANNEL',.*);/define('FOG_CHANNEL', '$channel');/g" $system_file
97+
sed -i "s/define('FOG_VERSION',.*);/define('FOG_VERSION', '$trunkversion');/g" "$system_file"
98+
sed -i "s/define('FOG_CHANNEL',.*);/define('FOG_CHANNEL', '$channel');/g" "$system_file"
10499

105100
# Add the modified system file to the staging area
106-
git add $system_file
101+
git add "$system_file"
102+

packages/web/lib/fog/system.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static function _versionCompare()
5353
public function __construct()
5454
{
5555
self::_versionCompare();
56-
define('FOG_VERSION', '1.5.10.1712');
56+
define('FOG_VERSION', '1.5.10.1713');
5757
define('FOG_SCHEMA', 273);
5858
define('FOG_BCACHE_VER', 141);
5959
define('FOG_CLIENT_VERSION', '0.13.0');

0 commit comments

Comments
 (0)