INNER CODE UNIT · Python
apply_group
emanuele-f/PCAPdroid · tools/weblate.py:158
def apply_group(group, path):
"""Apply a group's translation changes via 3-way merge.
Computes a diff spanning from the parent of the first commit to the
last commit in the group, then applies it with --3way so that
master-only changes (e.g. removed strings) are preserved.
"""
first = group["commits"][0]
last = group["commits"][-1]
first_parent = git("rev-parse", f"{first}^").stdout.strip()
patch = git("diff", "--full-index", first_parent, last, "--", path).stdout
if not patch.strip():
return
result = git("apply", "--3way", check=False, stdin=patch)
if result.returncode != 0:
die(f"Failed to apply changes for {path} "