Skip to content

Commit 594e68e

Browse files
committed
fix(code): Fix file permissions was not applied to modules
1 parent 89d5d1b commit 594e68e

File tree

6 files changed

+76
-30
lines changed

6 files changed

+76
-30
lines changed

bin/git-code.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function safeExit() {
88
scriptName="git code.check"
99
scriptArgs="<path>"
1010
verbose=false
11-
version=0.5.8
11+
version=0.5.9
1212
ecsImage=ghcr.io/justcoded/php-code-analysis:${version}
1313
#ecsImage=docker.io/library/dockerize-php-code-analysis-php-code-analysis-tool
1414
args=()

bin/git-code.check.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ scriptArgs="<path>"
1010
branch=develop
1111
verbose=false
1212
veryVerbose=false
13-
version=0.5.8
13+
version=0.5.9
1414
ecsImage=ghcr.io/justcoded/php-code-analysis:${version}
1515
#ecsImage=docker.io/library/dockerize-php-code-analysis-php-code-analysis-tool
1616
args=()

bin/git-code.check.dirty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ scriptName="git code.check.dirty"
99
scriptArgs="<path>"
1010
verbose=false
1111
veryVerbose=false
12-
version=0.5.8
12+
version=0.5.9
1313
ecsImage=ghcr.io/justcoded/php-code-analysis:${version}
1414
#ecsImage=docker.io/library/dockerize-php-code-analysis-php-code-analysis-tool
1515
args=()

bin/git-code.fix

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ scriptArgs="<path>"
1010
verbose=false
1111
veryVerbose=false
1212
fixPermissions=true
13-
version=0.5.8
13+
version=0.5.9
1414
ecsImage=ghcr.io/justcoded/php-code-analysis:${version}
1515
#ecsImage=docker.io/library/dockerize-php-code-analysis-php-code-analysis-tool
1616
args=()
@@ -72,6 +72,7 @@ function handle() {
7272
mapfile -t modifiedAfterPaths < <(git diff --name-only | grep '\.php$')
7373

7474
if $veryVerbose; then
75+
echo ''
7576
echo "Modified before files:"
7677
printf ' %s\n' "${modifiedBeforePaths[@]}"
7778
echo ''
@@ -159,21 +160,36 @@ fixPermissions() {
159160
return 0
160161
fi
161162

162-
chownPath=./
163+
chownPaths=()
163164

164-
if [ -d "$rootDir/src" ]; then
165-
chownPath='./src'
165+
if [[ -d "$rootDir/src" ]]; then
166+
chownPaths+=("$rootDir/src")
166167
fi
167168

168-
if [ -d "$rootDir/boilerplate/src" ]; then
169-
chownPath='./boilerplate/src'
169+
if [[ -d "$rootDir/boilerplate/src" ]]; then
170+
chownPaths+=("$rootDir/boilerplate/src")
170171
fi
171172

172-
if $veryVerbose; then
173-
echo "sudo chown -R $uid:$gid $chownPath"
173+
if [[ -d "$rootDir/modules" ]]; then
174+
chownPaths+=("$rootDir/modules")
174175
fi
175176

176-
(cd $rootDir && sudo chown -R $uid:$gid $chownPath)
177+
if [[ -d "$rootDir/private" ]]; then
178+
chownPaths+=("$rootDir/private")
179+
fi
180+
181+
if [[ -z "$chownPaths" ]]; then
182+
chownPaths+=("$rootDir")
183+
fi
184+
185+
# Run sudo chown for each path in the array
186+
for chownPath in "${chownPaths[@]}"; do
187+
if $veryVerbose; then
188+
echo "$chownPathArray sudo chown -R $uid:$gid "$chownPath""
189+
fi
190+
191+
sudo chown -R $uid:$gid "$chownPath"
192+
done
177193
}
178194

179195
greeting() {

bin/git-code.fix.diff

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ branch=develop
1111
verbose=false
1212
veryVerbose=false
1313
fixPermissions=true
14-
version=0.5.8
14+
version=0.5.9
1515
ecsImage=ghcr.io/justcoded/php-code-analysis:${version}
1616
#ecsImage=docker.io/library/dockerize-php-code-analysis-php-code-analysis-tool
1717
args=()
@@ -156,21 +156,36 @@ fixPermissions() {
156156
return 0
157157
fi
158158

159-
chownPath=./
159+
chownPaths=()
160160

161-
if [ -d "$rootDir/src" ]; then
162-
chownPath='./src'
161+
if [[ -d "$rootDir/src" ]]; then
162+
chownPaths+=("$rootDir/src")
163163
fi
164164

165-
if [ -d "$rootDir/boilerplate/src" ]; then
166-
chownPath='./src'
165+
if [[ -d "$rootDir/boilerplate/src" ]]; then
166+
chownPaths+=("$rootDir/boilerplate/src")
167167
fi
168168

169-
if $veryVerbose; then
170-
echo "sudo chown -R $uid:$gid $chownPath"
169+
if [[ -d "$rootDir/modules" ]]; then
170+
chownPaths+=("$rootDir/modules")
171+
fi
172+
173+
if [[ -d "$rootDir/private" ]]; then
174+
chownPaths+=("$rootDir/private")
175+
fi
176+
177+
if [[ -z "$chownPaths" ]]; then
178+
chownPaths+=("$rootDir")
171179
fi
172180

173-
(cd $rootDir && sudo chown -R $uid:$gid $chownPath)
181+
# Run sudo chown for each path in the array
182+
for chownPath in "${chownPaths[@]}"; do
183+
if $veryVerbose; then
184+
echo "$chownPathArray sudo chown -R $uid:$gid "$chownPath""
185+
fi
186+
187+
sudo chown -R $uid:$gid "$chownPath"
188+
done
174189
}
175190

176191
greeting() {

bin/git-code.fix.dirty

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ scriptArgs="<path>"
1010
verbose=false
1111
veryVerbose=false
1212
fixPermissions=true
13-
version=0.5.8
13+
version=0.5.9
1414
ecsImage=ghcr.io/justcoded/php-code-analysis:${version}
1515
#ecsImage=docker.io/library/dockerize-php-code-analysis-php-code-analysis-tool
1616
args=()
@@ -159,21 +159,36 @@ fixPermissions() {
159159
return 0
160160
fi
161161

162-
chownPath=./
162+
chownPaths=()
163163

164-
if [ -d "$rootDir/src" ]; then
165-
chownPath='./src'
164+
if [[ -d "$rootDir/src" ]]; then
165+
chownPaths+=("$rootDir/src")
166166
fi
167167

168-
if [ -d "$rootDir/boilerplate/src" ]; then
169-
chownPath='./src'
168+
if [[ -d "$rootDir/boilerplate/src" ]]; then
169+
chownPaths+=("$rootDir/boilerplate/src")
170170
fi
171171

172-
if $veryVerbose; then
173-
echo "sudo chown -R $uid:$gid $chownPath"
172+
if [[ -d "$rootDir/modules" ]]; then
173+
chownPaths+=("$rootDir/modules")
174+
fi
175+
176+
if [[ -d "$rootDir/private" ]]; then
177+
chownPaths+=("$rootDir/private")
178+
fi
179+
180+
if [[ -z "$chownPaths" ]]; then
181+
chownPaths+=("$rootDir")
174182
fi
175183

176-
(cd $rootDir && sudo chown -R $uid:$gid $chownPath)
184+
# Run sudo chown for each path in the array
185+
for chownPath in "${chownPaths[@]}"; do
186+
if $veryVerbose; then
187+
echo "$chownPathArray sudo chown -R $uid:$gid "$chownPath""
188+
fi
189+
190+
sudo chown -R $uid:$gid "$chownPath"
191+
done
177192
}
178193

179194
greeting() {

0 commit comments

Comments
 (0)