Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use moz.l10n diff instead of git diff #55

Merged
merged 2 commits into from
Jul 8, 2024
Merged

Use moz.l10n diff instead of git diff #55

merged 2 commits into from
Jul 8, 2024

Conversation

eemeli
Copy link
Member

@eemeli eemeli commented Jul 4, 2024

This uses the purpose-built l10n_equal() comparison function from moz.l10n.resource, which ignores irrelevant details like message order.

Filed initially as a draft, pending on mozilla/moz-l10n#9 and a subsequent release of moz.l10n v0.1.1.
Edit: Done.

@eemeli eemeli marked this pull request as ready for review July 4, 2024 14:12
@eemeli eemeli requested a review from a team as a code owner July 4, 2024 14:12
@@ -1,2 +1,3 @@
compare-locales ~= 9.0.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update to 9.0.4 since we're at this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not; I'm hoping to drop the c-l dependency in subsequent PRs. Also, ~= includes 9.0.4 so that's what we're already using in CI: https://github.com/mozilla-l10n/firefox-l10n-source/actions/runs/9830946288/job/27137710120#step:5:13

_scripts/diff.py Outdated Show resolved Hide resolved
_scripts/diff.py Outdated Show resolved Hide resolved
_scripts/diff.py Outdated Show resolved Hide resolved
for dirpath, dirnames, filenames in walk(a_root):
dirnames[:] = [dn for dn in dirnames if not dn.startswith((".", "_"))]
for fn in filenames:
if not fn.startswith((".", "_")):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even have files starting with _ that we want to ignore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have directories starting with _ to ignore, and it makes more sense to keep the rule for files as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case, would it make sense to put the check into a function? e.g. something along the line of

def ignore_global(name: str) -> bool:
	return name.startswith((".", "_"))

dirnames[:] = [dn for dn in dirnames if not ignore_global(dn)]

if not ignore_global(fn):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, sure, but this is a hacky utility script where code quality and maintainability really aren't paramount. If this thing lives for a long time, I'll refactor it to use moz.l10n.paths.L10nDiscoverPaths instead.

@flodolo flodolo requested a review from bcolsson July 8, 2024 07:08
_scripts/diff.py Outdated Show resolved Hide resolved
Co-authored-by: Francesco Lodolo <flod@lodolo.net>
for dirpath, dirnames, filenames in walk(a_root):
dirnames[:] = [dn for dn in dirnames if not dn.startswith((".", "_"))]
for fn in filenames:
if not fn.startswith((".", "_")):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case, would it make sense to put the check into a function? e.g. something along the line of

def ignore_global(name: str) -> bool:
	return name.startswith((".", "_"))

dirnames[:] = [dn for dn in dirnames if not ignore_global(dn)]

if not ignore_global(fn):

@eemeli eemeli merged commit b2b5e26 into main Jul 8, 2024
1 check passed
@eemeli eemeli deleted the moz-l10n-diff branch July 8, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants