Commit 779bcc87 authored by Michal Čihař's avatar Michal Čihař

Save only if there are some changes and push on commit

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent e1036ef8
...@@ -25,18 +25,22 @@ def build_index(storage): ...@@ -25,18 +25,22 @@ def build_index(storage):
def update_file(template, index, filename): def update_file(template, index, filename):
storage = RESXFile.parsefile(filename) storage = RESXFile.parsefile(filename)
sindex = build_index(storage) sindex = build_index(storage)
changed = False
# Add missing units # Add missing units
for unit in template.units: for unit in template.units:
if unit.getid() not in sindex: if unit.getid() not in sindex:
storage.addunit(unit, True) storage.addunit(unit, True)
changed = True
# Remove extra units # Remove extra units
for unit in storage.units: for unit in storage.units:
if unit.getid() not in index: if unit.getid() not in index:
storage.body.remove(unit.xmlelement) storage.body.remove(unit.xmlelement)
changed = True
storage.save() if changed:
storage.save()
def main(): def main():
...@@ -71,6 +75,8 @@ def main(): ...@@ -71,6 +75,8 @@ def main():
ret = subprocess.call( ret = subprocess.call(
['git', 'commit', '-a', '-m', 'Updated translation files'] ['git', 'commit', '-a', '-m', 'Updated translation files']
) )
if ret == 0:
ret = subprocess.call(['git', 'push'])
sys.exit(ret) sys.exit(ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment