Add support for updating the l10n last commit hash and new script option

This commit is contained in:
mr. M 2025-01-28 16:46:16 +01:00
parent c19748bbbe
commit 8d2e0b0a89
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
6 changed files with 31 additions and 6 deletions

2
.gitignore vendored
View file

@ -9,3 +9,5 @@ dist/
windsign-temp/
venv/
!firefox-cache/

View file

@ -0,0 +1 @@
ffe2107fb72c9893f7500ddd8f490adb436d71c7

0
l10n-last-commit-hash Normal file
View file

View file

@ -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",

View file

@ -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() {

View file

@ -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:
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}")