Skip to content

Commit cca2826

Browse files
committed
MDL-83424 support new directory structure
1 parent e3e164e commit cca2826

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

bumpversions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
$rc = Helper::getOption($options, 'r', 'rc');
4141
$date = Helper::getOption($options, 'd', 'date');
4242
$isdevbranch = (bool) Helper::getOption($options, 'i', 'isdevbranch');
43-
$path = rtrim($path, '/') . '/version.php';
43+
44+
// Find the version.php.
45+
$path = Helper::getVersionPath($path);
4446

4547
$release = Helper::bumpVersion($path, $branch, $type, $rc, $date, $isdevbranch);
4648
$result = 0;

get_next_version_number.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
$rc = Helper::getOption($options, 'r', 'rc');
4242
$date = Helper::getOption($options, 'd', 'date');
4343
$isdevbranch = (bool) Helper::getOption($options, 'i', 'isdevbranch');
44-
$path = rtrim($path, '/') . '/version.php';
44+
45+
// Find the version.php.
46+
$path = Helper::getVersionPath($path);
4547

4648
$currentVersion = VersionInfo::fromVersionFile($path);
4749
$nextVersion = $currentVersion->getNextVersion(

release.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,13 @@ skippedbranches=()
121121
output
122122
output "${normal}You are about to push:"
123123
for b in "${allbranches[@]}" ; do
124+
versionpath=version.php
125+
if [ ! -f $versionpath ]; then
126+
versionpath=public/version.php
127+
fi
128+
124129
# Search for a 'real' release by ensuring the top commit on version.php changes $release and was recent.
125-
releasebumped=$(git show --since='8 hours ago' -n1 origin/${b} version.php | grep "+\$release\s*=\s*")
130+
releasebumped=$(git show --since='8 hours ago' -n1 origin/${b} $versionpath | grep "+\$release\s*=\s*")
126131
if [[ -n ${releasebumped} || $_skip_version_check ]]; then
127132
output "${G}$b: ${normal}$(git log -n1 --pretty=format:"%s (%an %ar)" origin/$b)"
128133
# Check if between the last commit in the branch and now, it has been PUBLISHING_TIME (UTC)

src/Helper.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Helper
3030
/**
3131
* Bump the version.
3232
*
33-
* @param string $path The path to the versio file
33+
* @param string $path The path to the version file
3434
* @param string $branch The branch name to set
3535
* @param string $type The type of release
3636
* @param string $rc If a release candidate, the RC number
@@ -60,6 +60,30 @@ public static function bumpVersion(
6060
return $newVersionInfo->release;
6161
}
6262

63+
/**
64+
* Get the path to the version file.
65+
*
66+
* @param string $path Path to the Moodle root
67+
* @return string Path to version.php
68+
* @throws \ValueError if no version.php could be found
69+
*/
70+
public static function getVersionPath(
71+
string $path,
72+
): string {
73+
$possibles = [
74+
rtrim($path, '/') . '/public/version.php',
75+
rtrim($path, '/') . '/version.php',
76+
];
77+
78+
foreach ($possibles as $possible) {
79+
if (file_exists($possible)) {
80+
return $possible;
81+
}
82+
}
83+
84+
throw new \ValueError("Unable to find a version.php in {$path}");
85+
}
86+
6387
/**
6488
* Determine the next branch number based on the current one.
6589
*

0 commit comments

Comments
 (0)