5555 echo " + INFO: Not applying versions interval check (betweenversions environment variable)" >> " ${resultfile} "
5656fi
5757
58+ if [[ -d " ${gitdir} /public" || -f " ${gitdir} /public/version.php" ]]; then
59+ # If we have public directory, then use it as rootdir
60+ rootdir=" ${gitdir} /public"
61+ echo " + INFO: Using public directory as rootdir: ${rootdir} " >> " ${resultfile} "
62+ else
63+ rootdir=" ${gitdir} "
64+ echo " + INFO: Using gitdir as rootdir: ${gitdir} " >> " ${resultfile} "
65+ fi
66+
5867# First of all, guess the current branch from main version.php file ($branch). We'll be using
5968# it to decide about different checks later.
60- currentbranch=" $( grep " \$ branch.*=.*;" " ${gitdir } /version.php" || true ) "
69+ currentbranch=" $( grep " \$ branch.*=.*;" " ${rootdir } /version.php" || true ) "
6170if [ -z " ${currentbranch} " ]; then
6271 echo " + ERROR: Main version.php file is missing: \$ branch = 'xx' line." >> " ${resultfile} "
6372elif [[ ${currentbranch} =~ branch\ * = \ * .([0-9]{2,3}).\; ]]; then
7584# path (full or null)
7685${mydir} /../list_valid_components/list_valid_components.sh > " ${WORKSPACE} /valid_components.txt"
7786
78- # Find all the version.php files
87+ # Find all the version.php files in the gitdir.
88+ # Note: In 501 and earlier the version.php files were in the root of the gitdir.
89+ # In 501 and later they are in the public directory.
90+ # In future plugins may be in the root directory and not public.
91+ # So we need to find all version.php files in the gitdir.
7992allfiles=$( find " ${gitdir} " -name version.php | awk -F " /" ' {print NF-1"\t"$0}' | sort -n | cut -f 2- )
8093
8194# version.php files to ignore
82- ignorefiles=" (local/(ci|moodlecheck)/version.php|.*/tests/fixtures/.*/version.php)"
95+ ignorefiles=" (public/)?( local/(ci|moodlecheck)/version.php|.*/tests/fixtures/.*/version.php)"
8396
8497# Perform various checks with the version.php files
8598for i in ${allfiles} ; do
@@ -98,9 +111,9 @@ for i in ${allfiles}; do
98111
99112 # Calculate prefix for all the regexp operations below
100113 prefix=' \$plugin->'
101- if [ " ${i} " == " ${gitdir } /version.php" ]; then
114+ if [ " ${i} " == " ${rootdir } /version.php" ]; then
102115 prefix=' \$'
103- elif [[ " ${i} " =~ ${gitdir } /mod/[^/]* /version.php ]]; then
116+ elif [[ " ${i} " =~ ${rootdir } /mod/[^/]* /version.php ]]; then
104117 # Before 2.7, both "module" and "plugin" were allowed in core for activity modules. For 2.7 and up
105118 # only the default "plugin" is allowed.
106119 if [[ " ${currentbranch} " -lt " 27" ]]; then
@@ -183,7 +196,7 @@ for i in ${allfiles}; do
183196 fi
184197
185198 # If we are in main version.php
186- if [ " ${i} " == " ${gitdir} /version.php" ]; then
199+ if [[ " ${i} " == " ${gitdir} /version.php" || " ${i} " == " ${gitdir} /public/version.php " ] ]; then
187200 mainversion=${version}
188201
189202 mainrelease=" $( grep " ${prefix} release.*=.*;" ${i} || true ) "
@@ -366,12 +379,12 @@ for i in ${allfiles}; do
366379done
367380
368381# Now, look for backup/backup.class.php to ensure it matches main /version.php
369- echo " - ${gitdir } /backup/backup.class.php:" >> " ${resultfile} "
370- if [ ! -f " ${gitdir } /backup/backup.class.php" ]; then
382+ echo " - ${rootdir } /backup/backup.class.php:" >> " ${resultfile} "
383+ if [ ! -f " ${rootdir } /backup/backup.class.php" ]; then
371384 echo " + ERROR: File backup/backup.class.php not found" >> " ${resultfile} "
372385else
373386 # - backup::VERSION must be always >= $version (8 first digits comparison)
374- backupversion=" $( grep " const.*VERSION.*=.*;" " ${gitdir } /backup/backup.class.php" || true ) "
387+ backupversion=" $( grep " const.*VERSION.*=.*;" " ${rootdir } /backup/backup.class.php" || true ) "
375388 if [ -z " ${backupversion} " ]; then
376389 echo " + ERROR: backup/backup.class.php is missing: const VERSION = XXXXX line." >> " ${resultfile} "
377390 fi
398411 fi
399412
400413 # - backup::RELEASE must match $release (X.Y only)
401- backuprelease=" $( grep " const.*RELEASE.*=.*;" " ${gitdir } /backup/backup.class.php" || true ) "
414+ backuprelease=" $( grep " const.*RELEASE.*=.*;" " ${rootdir } /backup/backup.class.php" || true ) "
402415 if [ -z " ${backuprelease} " ]; then
403416 echo " + ERROR: backup/backup.class.php is missing: const RELEASE = 'X.Y' line." >> " ${resultfile} "
404417 fi
@@ -448,7 +461,7 @@ if [ ! -z "${setversion}" ] && (($count == 0)); then
448461 fi
449462 # Skip the main version.php file. Let's force to perform manual update there
450463 # (without it, upgrade won't work)
451- if [ " ${i} " == " ${gitdir } /version.php" ]; then
464+ if [ " ${i} " == " ${rootdir } /version.php" ]; then
452465 continue
453466 fi
454467 echo " - ${i} :" >> " ${resultfile} "
@@ -460,7 +473,7 @@ if [ ! -z "${setversion}" ] && (($count == 0)); then
460473 perl -p -i -e " ${replaceregex} " ${i}
461474 done
462475 # also the backup/backup.class.php file
463- i=${gitdir } /backup/backup.class.php
476+ i=${rootdir } /backup/backup.class.php
464477 echo " - ${i} :" >> " ${resultfile} "
465478 replaceregex=" s/(const *VERSION *= *)([0-9]{10}(\.[0-9]{2})?)/\$ {1}${setversion} /g"
466479 perl -p -i -e " ${replaceregex} " ${i}
0 commit comments