Skip to content

Instantly share code, notes, and snippets.

@bennuttall
Created April 9, 2021 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennuttall/0b57b7c2de52b9f5c7cd511a4c84c52a to your computer and use it in GitHub Desktop.
Save bennuttall/0b57b7c2de52b9f5c7cd511a4c84c52a to your computer and use it in GitHub Desktop.
from mosromgr.mostypes import MosFile
from glob import glob
from git import Repo
files = glob('*.mos.xml')
ro, *mosfiles = sorted(MosFile.from_file(f) for f in files)
repo = Repo.init('.')
ro_id = ro.ro_id.replace(';', '_')
ro_file = f'{ro_id}.mos.xml'
filename = f'{ro.message_id}-roCreate.mos.xml'
with open(ro_file, 'w') as f:
f.write(str(ro))
repo.index.add([ro_file])
repo.index.commit(f"Add {filename}")
for mf in mosfiles:
ro += mf
filename = f'{mf.message_id}-{mf.base_tag_name}.mos.xml'
with open(ro_file, 'w') as f:
f.write(str(ro))
repo.index.add([ro_file])
repo.index.commit(f"Merge {filename}")
@bennuttall
Copy link
Author

pip install mosromgr gitpython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment