Skip to content

Commit

Permalink
MDLSITE-7476 Migrate master to main
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jul 1, 2024
1 parent 5a009dc commit f3b92be
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions classes/local/git.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function is_success(string $args) : bool {
*/
public function list_local_branches() : array {

// Git returns values like 'refs/heads/master'. We want to strip the first two.
// Git returns values like 'refs/heads/main'. We want to strip the first two.
$list = $this->exec('for-each-ref --format="%(refname:strip=2)" '.escapeshellarg('refs/heads/'));

return $list;
Expand Down Expand Up @@ -170,7 +170,7 @@ public function has_remote_branch(string $name, string $remote='origin') : bool
*/
public function list_remote_branches(string $remote='origin') : array {

// Git returns values like 'refs/remotes/origin/master'. We want to strip the first three.
// Git returns values like 'refs/remotes/origin/main'. We want to strip the first three.
$list = $this->exec('for-each-ref --format="%(refname:strip=3)" '.escapeshellarg('refs/remotes/'.$remote));

// Get rid of the ref HEAD (which shows the default branch in
Expand Down
2 changes: 1 addition & 1 deletion classes/task/import_workplace_plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function get_branches_to_process() : array {
sort($listbranches, SORT_NATURAL);

foreach ($listbranches as $branchname) {
if ($branchname === 'master') {
if ($branchname === 'master' || $branchname === 'main') {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions cli/export-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
$exportdir = $version->code . '_STABLE';

} else if ($version->code == mlang_version::latest_version()->code) {
$gitbranch = 'origin/master';
$exportdir = 'master';
$gitbranch = 'origin/main';
$exportdir = 'main';

} else {
fputs(STDERR, "GIT BRANCH NOT FOUND FOR MOODLE VERSION {$version->label}\n");
Expand Down
4 changes: 2 additions & 2 deletions cli/fix-drift.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$cliresult = 0;

// Load the location of standard plugin types and core subsystems.
$componentsjson = (array) json_decode(implode(PHP_EOL, $git->exec('show origin/master:lib/components.json')), true);
$componentsjson = (array) json_decode(implode(PHP_EOL, $git->exec('show origin/main:lib/components.json')), true);
$plugintypelocations = $componentsjson['plugintypes'];

foreach (preg_split('|\R|', get_config('local_amos', 'plugintypelocations'), -1, PREG_SPLIT_NO_EMPTY) as $line) {
Expand All @@ -71,7 +71,7 @@
$gitbranch = 'origin/' . $version->branch;

} else if ($versioncode == max(array_keys($plugins))) {
$gitbranch = 'origin/master';
$gitbranch = 'origin/main';

} else {
cli_error('Git branch not found', 3);
Expand Down
2 changes: 1 addition & 1 deletion cli/parse-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function amos_parse_core_commit() {
$gitbranch = 'origin/' . $version->branch;

} else if ($version->code == mlang_version::latest_version()->code) {
$gitbranch = 'origin/master';
$gitbranch = 'origin/main';

} else {
fputs(STDERR, "GIT BRANCH NOT FOUND FOR MOODLE VERSION {$version->label}\n");
Expand Down
18 changes: 9 additions & 9 deletions jobs/install-packs-publish
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ on_exit() {
##
# Make sure that all required branches exist and are up to date.
#
# param $1 - name of the upstream branch such as master or MOODLE_311_STABLE
# param $2 - name of the install branch such as install_master or install_311_STABLE
# param $1 - name of the upstream branch such as main or MOODLE_311_STABLE
# param $2 - name of the install branch such as install_main or install_311_STABLE
#
prepare_branches() {
local upstreambranch=$1
Expand Down Expand Up @@ -59,8 +59,8 @@ prepare_branches() {
##
# Commit new install strings to the install branch.
#
# param $1 - name of the directory inside ${SRCROOT} to process such as master or 311_STABLE
# param $2 - name of the install branch such as install_master or install_311_STABLE
# param $1 - name of the directory inside ${SRCROOT} to process such as main or 311_STABLE
# param $2 - name of the install branch such as install_main or install_311_STABLE
#
commit_install_strings() {
local dirname=$1
Expand All @@ -80,8 +80,8 @@ commit_install_strings() {
##
# Push branches to remotes
#
# param $1 - name of the upstream branch such as master or MOODLE_311_STABLE
# param $2 - name of the install branch such as install_master or install_311_STABLE
# param $1 - name of the upstream branch such as main or MOODLE_311_STABLE
# param $2 - name of the install branch such as install_main or install_311_STABLE
#
publish_branches() {
local upstreambranch=$1
Expand All @@ -99,9 +99,9 @@ git remote update --prune
for DIR in ${SRCROOT}/*; do
if [[ -d ${DIR} ]]; then
DIRNAME=$(basename ${DIR})
if [[ ${DIRNAME} = "master" ]]; then
UPSTREAMBRANCH="master"
INSTALLBRANCH="install_master"
if [[ ${DIRNAME} = "main" ]]; then
UPSTREAMBRANCH="main"
INSTALLBRANCH="install_main"
else
UPSTREAMBRANCH="MOODLE_${DIRNAME}"
INSTALLBRANCH="install_${DIRNAME}"
Expand Down
6 changes: 3 additions & 3 deletions mlanglib.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,11 @@ public function get_phpfile_location($treeish=true) {
*
* This may be used to get rid of strings that are not defined in another component.
* Typically can be used to clean the translation from strings that are not defined in
* the master English pack.
* the English pack.
* Beware - if the string is defined in $mask as deleted, it will be kept in this regardless
* its state.
*
* @param mlang_component $mask master component to compare strings with
* @param mlang_component $mask component to compare strings with
* @return int number of removed strings
*/
public function intersect(mlang_component $mask) {
Expand All @@ -571,7 +571,7 @@ public function intersect(mlang_component $mask) {
* regardless its state and value. Our strings that are already deleted are not
* affected.
*
* @param mlang_component $reference master component to compare strings with
* @param mlang_component $reference component to compare strings with
* @return array list of removed string ids
*/
public function complement(mlang_component $reference) {
Expand Down
30 changes: 15 additions & 15 deletions tests/mlanglib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1119,21 +1119,21 @@ public function test_get_string_keys() {
}

public function test_intersect() {
$master = new mlang_component('moodle', 'en', mlang_version::by_branch('MOODLE_18_STABLE'));
$master->add_string(new mlang_string('one', 'One'));
$master->add_string(new mlang_string('two', 'Two'));
$master->add_string(new mlang_string('three', 'Three'));

$slave = new mlang_component('moodle', 'cs', mlang_version::by_branch('MOODLE_18_STABLE'));
$slave->add_string(new mlang_string('one', 'Jedna'));
$slave->add_string(new mlang_string('two', 'Dva'));
$slave->add_string(new mlang_string('seven', 'Sedm'));
$slave->add_string(new mlang_string('eight', 'Osm'));

$slave->intersect($master);
$this->assertEquals(2, count($slave->get_string_keys()));
$this->assertTrue($slave->has_string('one'));
$this->assertTrue($slave->has_string('two'));
$comp1 = new mlang_component('moodle', 'en', mlang_version::by_branch('MOODLE_18_STABLE'));
$comp1->add_string(new mlang_string('one', 'One'));
$comp1->add_string(new mlang_string('two', 'Two'));
$comp1->add_string(new mlang_string('three', 'Three'));

$comp2 = new mlang_component('moodle', 'cs', mlang_version::by_branch('MOODLE_18_STABLE'));
$comp2->add_string(new mlang_string('one', 'Jedna'));
$comp2->add_string(new mlang_string('two', 'Dva'));
$comp2->add_string(new mlang_string('seven', 'Sedm'));
$comp2->add_string(new mlang_string('eight', 'Osm'));

$comp2->intersect($comp1);
$this->assertEquals(2, count($comp2->get_string_keys()));
$this->assertTrue($comp2->has_string('one'));
$this->assertTrue($comp2->has_string('two'));
}

public function test_extract_script_from_text() {
Expand Down

0 comments on commit f3b92be

Please sign in to comment.