Skip to content

Commit

Permalink
Add support for updating the l10n last commit hash and new script option
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-balades committed Jan 28, 2025
1 parent c19748b commit 8d2e0b0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist/

windsign-temp/
venv/

!firefox-cache/
1 change: 1 addition & 0 deletions firefox-cache/l10n-last-commit-hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ffe2107fb72c9893f7500ddd8f490adb436d71c7
Empty file added l10n-last-commit-hash
Empty file.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions scripts/download-language-packs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
28 changes: 22 additions & 6 deletions scripts/update_ff.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,38 @@ 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."""

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

Expand Down

0 comments on commit 8d2e0b0

Please sign in to comment.