Restore visual_scale support for nodeboxes (and allfaces) (#9906)
[oweals/minetest.git] / util / reorder_translation_commits.py
1 #!/usr/bin/env python3
2 import sys
3 import subprocess
4
5 ret = subprocess.run(["git", "config", "rebase.instructionFormat"], capture_output=True)
6 if ret.returncode != 0 or ret.stdout.decode('ascii').strip() != "(%an <%ae>) %s":
7         print("Git is using the wrong rebase instruction format, reconfigure it.")
8         exit(1)
9
10 try:
11         f = open(".git/rebase-merge/git-rebase-todo", "r")
12 except:
13         print("Initiate the rebase first!")
14         exit(1)
15 lines = list(s.strip("\r\n") for s in f.readlines())
16 f.close()
17
18 for i in range(len(lines)):
19         line = lines[i]
20         if line.startswith("#") or " Translated using Weblate " not in line: continue
21         pos = line.rfind("(")
22         lang = line[pos:]
23         author = line[line.find("("):line.rfind(")", 0, pos)+1]
24         # try to grab the next commit by the same author for the same language
25         for j in range(i+1, len(lines)):
26                 if lines[j].startswith("#") or not lines[j].endswith(lang): continue
27                 if author in lines[j]:
28                         lines.insert(i+1, "f " + lines.pop(j)[5:])
29                 break
30
31 with open(".git/rebase-merge/git-rebase-todo", "w") as f:
32         f.write("\n".join(lines) + "\n")
33 print("You can now continue with the rebase.")