From 8d2e0b0a89790cdbac1ef2ca822ab0738a3edae6 Mon Sep 17 00:00:00 2001 From: "mr. M" Date: Tue, 28 Jan 2025 16:46:16 +0100 Subject: [PATCH] Add support for updating the l10n last commit hash and new script option --- .gitignore | 2 ++ firefox-cache/l10n-last-commit-hash | 1 + l10n-last-commit-hash | 0 package.json | 1 + scripts/download-language-packs.sh | 5 +++++ scripts/update_ff.py | 28 ++++++++++++++++++++++------ 6 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 firefox-cache/l10n-last-commit-hash create mode 100644 l10n-last-commit-hash diff --git a/.gitignore b/.gitignore index d57494754..e8be44c7a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ dist/ windsign-temp/ venv/ + +!firefox-cache/ diff --git a/firefox-cache/l10n-last-commit-hash b/firefox-cache/l10n-last-commit-hash new file mode 100644 index 000000000..9c4d6bdda --- /dev/null +++ b/firefox-cache/l10n-last-commit-hash @@ -0,0 +1 @@ +ffe2107fb72c9893f7500ddd8f490adb436d71c7 diff --git a/l10n-last-commit-hash b/l10n-last-commit-hash new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json index 4f334a15d..c943fddc5 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "update-ff:raw": "surfer update", "update-newtab": "python3 scripts/update_newtab.py", "update-ff:rc": "python3 scripts/update_ff.py --rc", + "update-ff:l10n": "python3 scripts/update_ff.py --just-l10n", "pretty": "prettier . --write && autopep8 -r --in-place scripts/ src/", "lint": "npx prettier . --check && autopep8 --diff scripts/ src/", "prepare": "husky", diff --git a/scripts/download-language-packs.sh b/scripts/download-language-packs.sh index f59e96312..11f472592 100644 --- a/scripts/download-language-packs.sh +++ b/scripts/download-language-packs.sh @@ -7,8 +7,13 @@ git config --global fetch.prune true cd $CURRENT_DIR +LAST_FIREFOX_L10N_COMMIT=$(cat ./firefox-cache/l10n-last-commit-hash) + cd ./l10n +# clone only from LAST_FIREFOX_L10N_COMMIT git clone https://github.com/mozilla-l10n/firefox-l10n +cd firefox-l10n +git checkout $LAST_FIREFOX_L10N_COMMIT cd $CURRENT_DIR update_language() { diff --git a/scripts/update_ff.py b/scripts/update_ff.py index 2cbe1f358..a42dc6790 100644 --- a/scripts/update_ff.py +++ b/scripts/update_ff.py @@ -56,6 +56,17 @@ def update_readme(last_version, new_version, is_rc=False): except FileNotFoundError as e: raise RuntimeError(f"README.md file not found: {e}") +def update_l10n_last_commit_hash(): + L10N_REPO = "https://github.com/mozilla-l10n/firefox-l10n" + try: + os.system(f"git clone {L10N_REPO} l10n-temp") + if not os.path.exists("firefox-cache"): + os.mkdir("firefox-cache") + with open("l10n-last-commit-hash", "w") as f: + os.system("cat l10n-temp/.git/refs/heads/main > firefox-cache/l10n-last-commit-hash") + except KeyboardInterrupt: + print("Exiting...") + shutil.rmtree("l10n-temp") def main(): """Main function to update versions and README.""" @@ -63,15 +74,20 @@ def main(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument( "--rc", help="Indicates that this is a release candidate.", default=False, action="store_true") + arg_parser.add_argument( + "--just-l10n", help="Only update the l10n last commit hash.", default=False, action="store_true") args = arg_parser.parse_args() try: - last_version = get_version_from_file("surfer.json", args.rc) - update_ff(args.rc, last_version) - new_version = get_version_from_file("surfer.json", args.rc) - update_readme(last_version, new_version, args.rc) - print( - f"Updated version from {last_version} to {new_version} in README.md.") + if not args.just_l10n: + last_version = get_version_from_file("surfer.json", args.rc) + update_ff(args.rc, last_version) + new_version = get_version_from_file("surfer.json", args.rc) + update_readme(last_version, new_version, args.rc) + print( + f"Updated version from {last_version} to {new_version} in README.md.") + print("Updating l10n last commit hash.") + update_l10n_last_commit_hash() except Exception as e: print(f"An error occurred: {e}")