From c81e9af064b8de1e1576b7fa7aea2b0e5977078e Mon Sep 17 00:00:00 2001 From: Francesco Lodolo Date: Thu, 15 Aug 2024 13:10:24 +0200 Subject: [PATCH] Switch Thunderbird and Seamonkey to Git (#1039) --- app/classes/Transvision/Project.php | 27 +++++++----- app/classes/Transvision/VersionControl.php | 51 ++++++++-------------- app/scripts/bash_variables.sh | 13 ++++-- app/scripts/clean_data.py | 3 +- app/scripts/glossaire.sh | 29 ++++++------ app/scripts/setup.sh | 37 ++++++++++++---- tests/units/Transvision/Project.php | 2 +- tests/units/Transvision/VersionControl.php | 49 +++++++++++---------- 8 files changed, 116 insertions(+), 95 deletions(-) diff --git a/app/classes/Transvision/Project.php b/app/classes/Transvision/Project.php index 415524a3..f69f6710 100644 --- a/app/classes/Transvision/Project.php +++ b/app/classes/Transvision/Project.php @@ -18,7 +18,7 @@ class Project * * files: list of files to analyze during extraction * - * git_repository: name of remote Git repository in the mozilla-l10n org + * git_repository: name of remote Git repository * * git_subfolder: if localizations are in a subdirectory, e.g. if they're * subfolders in /locales, value will be simply "locales" (no ending or @@ -48,7 +48,7 @@ class Project 'meta' => true, ], 'firefox_ios' => [ - 'git_repository' => 'firefoxios-l10n', + 'git_repository' => 'mozilla-l10n/firefoxios-l10n', 'locale_mapping' => [ 'bn-IN' => 'bn', 'bn-BD' => 'bn', @@ -60,17 +60,23 @@ class Project 'variable_patterns' => ['ios'], ], 'gecko_strings'=> [ - 'git_repository' => 'firefox-l10n', + 'git_repository' => 'mozilla-l10n/firefox-l10n', 'git_branch' => 'main', 'source_type' => 'mixed', 'variable_patterns' => ['dtd', 'ftl', 'l10njs', 'printf', 'properties'], ], - 'comm_l10n' => [ + 'seamonkey' => [ + 'git_repository' => 'seamonkey-project/seamonkey-central-l10n', 'source_type' => 'mixed', - 'variable_patterns' => ['dtd', 'ftl', 'l10njs', 'printf', 'properties'], + 'variable_patterns' => ['dtd', 'ftl', 'printf', 'properties'], + ], + 'thunderbird' => [ + 'git_repository' => 'thunderbird/thunderbird-l10n', + 'source_type' => 'mixed', + 'variable_patterns' => ['dtd', 'ftl', 'printf', 'properties'], ], 'mozilla_org' => [ - 'git_repository' => 'www-l10n', + 'git_repository' => 'mozilla-l10n/www-l10n', 'git_branch' => 'master', 'pontoon_project' => 'mozillaorg', 'reference_locale' => 'en', @@ -78,7 +84,7 @@ class Project 'variable_patterns' => ['ftl'], ], 'android_l10n' => [ - 'git_repository' => 'android-l10n', + 'git_repository' => 'mozilla-l10n/android-l10n', 'git_branch' => 'master', 'locale_mapping' => [], // To avoid using Bugzilla 'pontoon_project' => 'android-l10n', @@ -86,7 +92,7 @@ class Project 'variable_patterns' => ['xml_android'], ], 'vpn_client' => [ - 'git_repository' => 'mozilla-vpn-client-l10n', + 'git_repository' => 'mozilla-l10n/mozilla-vpn-client-l10n', 'underscore_locales' => true, 'pontoon_project' => 'mozilla-vpn-client', 'reference_locale' => 'en', @@ -103,12 +109,13 @@ class Project // Desktop products 'desktop' => [ 'gecko_strings', - 'comm_l10n', + 'seamonkey', + 'thunderbird', ], // Products using Git 'git' => [ 'android_l10n', 'firefox_ios', 'gecko_strings', 'mozilla_org', - 'vpn_client', + 'seamonkey', 'thunderbird', 'vpn_client', ], // Products using free text search on Pontoon 'text_search' => [ diff --git a/app/classes/Transvision/VersionControl.php b/app/classes/Transvision/VersionControl.php index b9919621..731d75c1 100644 --- a/app/classes/Transvision/VersionControl.php +++ b/app/classes/Transvision/VersionControl.php @@ -70,9 +70,6 @@ public static function getPath($locale, $repo, $path) case 'git': $path = self::gitPath($locale, $repo, $path); break; - case 'hg': - $path = self::hgPath($locale, $repo, $path); - break; default: $path = ''; break; @@ -81,32 +78,6 @@ public static function getPath($locale, $repo, $path) return $path; } - /** - * Generate a path to the mercurial repo for the file - * - * @param string $locale Locale code - * @param string $repo Repository name - * @param string $path Entity name representing the local file - * - * @return string Path to the file in remote mercurial repository - */ - public static function hgPath($locale, $repo, $path) - { - // Remove entity from path and store it in a variable - $path = explode(':', $path); - $path = $path[0]; - $path = explode('/', $path); - $entity_file = array_pop($path); - $path = implode('/', $path); - $exploded_path = explode('/', $path); - $base_folder = $exploded_path[0]; - - # comm-l10n is the last repository using Mercurial - $url = "https://hg.mozilla.org/projects/comm-l10n/file/default/{$locale}/"; - - return $url . $path . '/' . $entity_file; - } - /** * Generate a path to the GitHub repo for the file. * @@ -129,13 +100,25 @@ public static function gitPath($locale, $repo, $path) $file_path = "{$repo_data['git_subfolder']}/{$file_path}"; } if ($repo == 'gecko_strings') { - // Special case for gecko-strings (Firefox) $file_path = explode(':', $path)[0]; if ($locale == 'en-US') { return "https://github.com/mozilla-l10n/firefox-l10n-source/blob/main/{$file_path}"; } - return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}"; + return "https://github.com/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}"; + } + if ($repo == 'seamonkey') { + $file_path = explode(':', $path)[0]; + + return "https://gitlab.com/{$git_repo}/-/blob/{$git_branch}/{$locale}/{$file_path}"; + } + if ($repo == 'thunderbird') { + $file_path = explode(':', $path)[0]; + if ($locale == 'en-US') { + return "https://github.com/thunderbird/thunderbird-l10n-source/blob/main/{$file_path}"; + } + + return "https://github.com/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}"; } if ($repo == 'android_l10n') { // Special case for android-l10n (Android) @@ -144,7 +127,7 @@ public static function gitPath($locale, $repo, $path) : '-' . str_replace('-', '-r', $locale); $file_path = str_replace('values', "values{$locale_android}", $file_path); - return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$file_path}"; + return "https://github.com/{$git_repo}/blob/{$git_branch}/{$file_path}"; } if ($repo == 'mozilla_org') { // Special case for mozilla.org (Fluent) @@ -152,7 +135,7 @@ public static function gitPath($locale, $repo, $path) $file_path = str_replace('en/', "{$locale}/", $file_path); } - return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$file_path}"; + return "https://github.com/{$git_repo}/blob/{$git_branch}/{$file_path}"; } } else { $file_path = $path; @@ -160,7 +143,7 @@ public static function gitPath($locale, $repo, $path) $git_branch = 'main'; } - return "https://github.com/mozilla-l10n/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}"; + return "https://github.com/{$git_repo}/blob/{$git_branch}/{$locale}/{$file_path}"; } /** diff --git a/app/scripts/bash_variables.sh b/app/scripts/bash_variables.sh index 74284e11..55f51318 100644 --- a/app/scripts/bash_variables.sh +++ b/app/scripts/bash_variables.sh @@ -11,10 +11,15 @@ gecko_strings_path=${local_git}/gecko_strings gecko_strings_locales=${path_sources}/gecko_strings.txt folders+=( $gecko_strings_path ) -# Path and list of locales for comm-l10n -comm_l10n_locales=${path_sources}/comm_l10n.txt -comm_l10n_path=${local_hg}/comm_l10n -folders+=( $comm_l10n_path ) +# Path and list of locales for Thunderbird +thunderbird_locales=${path_sources}/thunderbird.txt +thunderbird_path=${local_git}/thunderbird +folders+=( $thunderbird_path ) + +# Path and list of locales for Seamonkey +seamonkey_locales=${path_sources}/seamonkey.txt +seamonkey_path=${local_git}/seamonkey +folders+=( $seamonkey_path ) # Location of mozilla.org repository (Fluent based) mozilla_org=$local_git/mozilla_org/ diff --git a/app/scripts/clean_data.py b/app/scripts/clean_data.py index 972e4ebe..4594906a 100644 --- a/app/scripts/clean_data.py +++ b/app/scripts/clean_data.py @@ -96,9 +96,10 @@ def main(): # Besides standard VCS folders or templates, we need to exclude some # folders in specific projects. excluded_folders = { - "comm_l10n": ["ja-JP-mac"], "firefox_ios": ["templates", "es"], "mozilla_org": ["configs", "en"], + "seamonkey": ["ja-JP-mac"], + "thunderbird": ["ja-JP-mac"], "vpn_client": ["en"], } diff --git a/app/scripts/glossaire.sh b/app/scripts/glossaire.sh index 34e8cda3..afdae272 100755 --- a/app/scripts/glossaire.sh +++ b/app/scripts/glossaire.sh @@ -111,7 +111,7 @@ fi # Create all bash variables source $script_path/bash_variables.sh -function updateGeckoStrings() { +function updateMultirepo() { function buildCache() { # Build the cache # $1: Path containing locale folder @@ -123,9 +123,11 @@ function updateGeckoStrings() { nice -20 python $install/app/scripts/tmx/tmx_products.py --path $path/$locale/ --locale $locale --ref en-US --repo $repo_name } - local repo_name="gecko_strings" - local repo_folder="$gecko_strings_path" - local locale_list="gecko_strings_locales" + local repo_name="$1" + local var_repo_path="$1_path" + local var_locales_list="$1_locales" + local repo_folder=${!var_repo_path} + local locale_list=${!var_locales_list} # Update en-US, create TMX for en-US git -C $repo_folder/en-US pull @@ -139,7 +141,7 @@ function updateGeckoStrings() { if [ "$all_locales" = true ] then - locales=$(cat ${!locale_list}) + locales=$(cat $locale_list) else locales=($locale_code) fi @@ -158,7 +160,7 @@ function updateGeckoStrings() { done } -function updateCommL10n() { +function updateSeamonkey() { function buildCache() { # Build the cache # $1: Locale code @@ -167,15 +169,15 @@ function updateCommL10n() { nice -20 python $install/app/scripts/tmx/tmx_products.py --path $repo_folder/$1/ --locale $1 --ref en-US --repo $repo_name } - local repo_name="comm_l10n" - local repo_folder="$comm_l10n_path" - local locale_list="comm_l10n_locales" + local repo_name="seamonkey" + local repo_folder="$seamonkey_path" + local locale_list="seamonkey_locales" if [ "$checkrepo" = true ] then # Pull repo - echogreen "Update comm-l10n repository" - hg --cwd $repo_folder pull --update -r default + echogreen "Update seamonkey repository" + git -C $repo_folder pull fi # Build cache for en-US first, then other locales @@ -231,8 +233,9 @@ function updateMozOrg() { echogreen "Activating virtualenv..." source $install/python-venv/bin/activate || exit 1 -updateGeckoStrings -updateCommL10n +updateMultirepo gecko_strings +updateMultirepo thunderbird +updateSeamonkey updateMozOrg updateOtherProduct firefox_ios "Firefox for iOS" tmx_xliff updateOtherProduct vpn_client "Mozilla VPN Client" tmx_xliff diff --git a/app/scripts/setup.sh b/app/scripts/setup.sh index 22e3d292..162d819b 100755 --- a/app/scripts/setup.sh +++ b/app/scripts/setup.sh @@ -42,7 +42,6 @@ function setupVirtualEnv() { function initGeckoStringsRepo() { local repo_folder="gecko_strings_path" - local repo_path="https://hg.mozilla.org/l10n-central" # If repo_folder="gecko_strings_path", ${!repo_folder} is equal to $gecko_strings_path cd ${!repo_folder} @@ -62,14 +61,35 @@ function initGeckoStringsRepo() { fi } -function initCommL10nRepo() { - local repo_folder="comm_l10n_path" +function initThunderbirdRepo() { + local repo_folder="thunderbird_path" - if [ ! -d ${!repo_folder}/.hg ] + # If repo_folder="thunderbird_path", ${!repo_folder} is equal to $thunderbird_path + cd ${!repo_folder} + + # Clone source repository as en-US + if [ ! -d "en-US" ]; + then + echogreen "Checking out thunderbird-l10n-source" + git clone https://github.com/thunderbird/thunderbird-l10n-source en-US + fi + + # Clone l10n monorepo as l10n + if [ ! -d "l10n" ]; + then + echogreen "Checking out thunderbird-l10n" + git clone https://github.com/thunderbird/thunderbird-l10n l10n + fi +} + +function initSeamonkeyRepo() { + local repo_folder="seamonkey_path" + + if [ ! -d ${!repo_folder}/.git ] then - echogreen "Checking out comm-l10n repo." - cd ${local_hg} - hg clone https://hg.mozilla.org/projects/comm-l10n/ comm_l10n + echogreen "Checking out seamonkey-central-l10n repo." + cd ${local_git} + git clone https://gitlab.com/seamonkey-project/seamonkey-central-l10n seamonkey fi } @@ -158,7 +178,8 @@ echo "${LATEST_TAG_NAME}" | tr -d '\n' > "${install}/cache/tag.txt" setupVirtualEnv initGeckoStringsRepo -initCommL10nRepo +initThunderbirdRepo +initSeamonkeyRepo # Check out GitHub repos cd $mozilla_org diff --git a/tests/units/Transvision/Project.php b/tests/units/Transvision/Project.php index ec1268cc..1ca7d5ed 100644 --- a/tests/units/Transvision/Project.php +++ b/tests/units/Transvision/Project.php @@ -74,7 +74,7 @@ public function testGetRepositoriesNames() public function testGetDesktopRepositories() { $obj = new _Project(); - $repos = ['gecko_strings', 'comm_l10n']; + $repos = ['gecko_strings', 'seamonkey', 'thunderbird']; $this ->array($obj->getDesktopRepositories()) ->isEqualTo($repos); diff --git a/tests/units/Transvision/VersionControl.php b/tests/units/Transvision/VersionControl.php index 1e24dc0d..bbfe1f7d 100644 --- a/tests/units/Transvision/VersionControl.php +++ b/tests/units/Transvision/VersionControl.php @@ -60,29 +60,6 @@ public function testVCSRepoName($a, $b) ->isEqualTo($b); } - public function hgPathDP() - { - return [ - [ - 'en-US', - 'comm_l10n', - 'mail/branding/thunderbird/brand.dtd:brandFullName', - 'https://hg.mozilla.org/projects/comm-l10n/file/default/en-US/mail/branding/thunderbird/brand.dtd', - ], - ]; - } - - /** - * @dataProvider hgPathDP - */ - public function testHgPath($a, $b, $c, $d) - { - $obj = new _VersionControl(); - $this - ->string($obj->hgPath($a, $b, $c)) - ->isEqualTo($d); - } - public function gitPathDP() { return [ @@ -108,7 +85,7 @@ public function gitPathDP() 'fr', 'unknown', 'test/file.properties', - 'https://github.com/mozilla-l10n/unknown/blob/main/fr/test/file.properties', + 'https://github.com/unknown/blob/main/fr/test/file.properties', ], [ 'en-US', @@ -157,6 +134,30 @@ public function getPathDP() 'browser/updater/updater.ini:TitleText', 'https://github.com/mozilla-l10n/firefox-l10n/blob/main/fr/browser/updater/updater.ini', ], + [ + 'en-US', + 'thunderbird', + 'browser/updater/updater.ini:TitleText', + 'https://github.com/thunderbird/thunderbird-l10n-source/blob/main/browser/updater/updater.ini', + ], + [ + 'fr', + 'thunderbird', + 'browser/updater/updater.ini:TitleText', + 'https://github.com/thunderbird/thunderbird-l10n/blob/main/fr/browser/updater/updater.ini', + ], + [ + 'en-US', + 'seamonkey', + 'browser/updater/updater.ini:TitleText', + 'https://gitlab.com/seamonkey-project/seamonkey-central-l10n/-/blob/main/en-US/browser/updater/updater.ini', + ], + [ + 'fr', + 'seamonkey', + 'browser/updater/updater.ini:TitleText', + 'https://gitlab.com/seamonkey-project/seamonkey-central-l10n/-/blob/main/fr/browser/updater/updater.ini', + ], [ 'it', 'firefox_ios',