mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-05-08 21:12:26 +00:00
weblate.py: consider locale up-to-date when files match
Skip update and bump status when the locale file is identical on weblate/master and HEAD. Also bump status when all pending commits are already in master.
This commit is contained in:
+20
-3
@@ -109,6 +109,12 @@ def translation_pct(locale):
|
||||
translated = count_strings(locale_result.stdout)
|
||||
return f"{100 * translated // total}%"
|
||||
|
||||
def locale_in_sync(locale):
|
||||
"""True if the locale file is identical on weblate/master and HEAD."""
|
||||
path = locale_path(locale)
|
||||
return git("diff", "--quiet", f"{REMOTE}/master", "HEAD", "--", path,
|
||||
check=False).returncode == 0
|
||||
|
||||
def working_tree_clean():
|
||||
return git("diff", "--quiet", "--", STRINGS_BASE, check=False).returncode == 0 and \
|
||||
git("diff", "--cached", "--quiet", "--", STRINGS_BASE, check=False).returncode == 0
|
||||
@@ -196,7 +202,7 @@ def cmd_status():
|
||||
if last:
|
||||
pending = get_pending_commits(locale, last)
|
||||
translation = [c for c in pending if not is_on_master(c)]
|
||||
if translation:
|
||||
if translation and not locale_in_sync(locale):
|
||||
print(f" {locale} ({pct}): {len(translation)} pending translation commit(s)")
|
||||
else:
|
||||
print(f" {locale} ({pct}): up-to-date")
|
||||
@@ -205,7 +211,7 @@ def cmd_status():
|
||||
if not pending:
|
||||
continue
|
||||
translation = [c for c in pending if not is_on_master(c)]
|
||||
if not translation:
|
||||
if (not translation) or locale_in_sync(locale):
|
||||
continue
|
||||
if locale_exists_on_disk(locale):
|
||||
print(f" {locale} ({pct}): NOT TRACKED (exists on disk, "
|
||||
@@ -231,7 +237,15 @@ def update_locale(locale, status):
|
||||
skipped = len(all_pending) - len(pending)
|
||||
|
||||
if not pending:
|
||||
print(f" {locale}: {skipped} commit(s) already in master, nothing to do")
|
||||
print(f" {locale}: {skipped} commit(s) already in master, bumping status")
|
||||
status[locale] = all_pending[-1]
|
||||
save_status(status)
|
||||
return
|
||||
|
||||
if locale_in_sync(locale):
|
||||
print(f" {locale}: already in sync, bumping status")
|
||||
status[locale] = pending[-1]
|
||||
save_status(status)
|
||||
return
|
||||
|
||||
extra = f" ({skipped} already in master)" if skipped else ""
|
||||
@@ -264,6 +278,9 @@ def update_locale(locale, status):
|
||||
# range for the next run stays on the weblate lineage
|
||||
status[locale] = pending[-1]
|
||||
save_status(status)
|
||||
git("add", STATUS_FILE)
|
||||
if has_staged_changes():
|
||||
git("commit", "--amend", "--no-edit")
|
||||
print(f" {locale}: done")
|
||||
|
||||
def cmd_update(target_locale=None):
|
||||
|
||||
+10
-10
@@ -1,13 +1,13 @@
|
||||
ar=c88b846da7548f95c361f19f1d6baa304899dd1c
|
||||
az=5ee3868efbbb6d6b390f6c10f3b16d1e7ebd8422
|
||||
de=5fc8414f6732b58fd40a4f5cda46992d0d025e7f
|
||||
ar=69e383df015e8d9e9b080acba486eacc866beb8e
|
||||
az=f70d92c58afefd267b4bbd5272e18519c311807e
|
||||
de=031ad3429b17bb22062224589b4f0c4fd48dfa38
|
||||
es=e9e35f8bb54d1b044de74d37010090b809144e2a
|
||||
in=6d135bdda6c868b30f7a477aa66f9b181220ed06
|
||||
it=fbf7a9b8c50cd0d789b5bdfd93b0330755e7179b
|
||||
in=5e34648e9f5df34dd3847cc5df977da45d7c1cc7
|
||||
it=92052bcc262a5241cb2cc3f75c3f48ba7726d493
|
||||
pl=e9e35f8bb54d1b044de74d37010090b809144e2a
|
||||
pt-rBR=b077530a74c4fdfd541d5a9d05d4a8a569a516ca
|
||||
ru=4604a361e0d797e84985ab93daa5f39898cdf58f
|
||||
ta=2cfd5d7a6e380a8468e694dab69d0fbeb07a0f0e
|
||||
tr=2908b0a26800b56e4378b60f2e0c57a3322db1b0
|
||||
pt-rBR=75a196ca1018b99f053e291be2a753f025eda6ee
|
||||
ru=553966e3820ba9c3697151cf1406e5102044fc2f
|
||||
ta=0d64e4560626fee6bd69c82eb8fcc9a3084441e8
|
||||
tr=271737b524caf42484a93619b805617386ceeb47
|
||||
uk=e9e35f8bb54d1b044de74d37010090b809144e2a
|
||||
zh-rCN=f507279aa45b7681da1a216633011427a5cd4dcc
|
||||
zh-rCN=900c2de2fb9503e23c4bdaa0e9f6d7809f648e10
|
||||
|
||||
Reference in New Issue
Block a user