More hacking, it is kinda working a bit more
This commit is contained in:
33
tyop.py
33
tyop.py
@ -48,6 +48,7 @@ class Migration:
|
|||||||
yaml.preserve_quotes = True
|
yaml.preserve_quotes = True
|
||||||
yaml.indent(mapping=2, sequence=4, offset=2)
|
yaml.indent(mapping=2, sequence=4, offset=2)
|
||||||
yaml.allow_duplicate_keys = True
|
yaml.allow_duplicate_keys = True
|
||||||
|
yaml.width = 999999
|
||||||
return yaml
|
return yaml
|
||||||
|
|
||||||
def _exit(self, msg="Bailing out on request...", code=1):
|
def _exit(self, msg="Bailing out on request...", code=1):
|
||||||
@ -132,17 +133,17 @@ class Migration:
|
|||||||
def _message(self):
|
def _message(self):
|
||||||
return input("Commit message? ")
|
return input("Commit message? ")
|
||||||
|
|
||||||
def _commit(self, match):
|
def _commit(self):
|
||||||
root_path = Path(match).parent
|
for path in self.paths[:1]:
|
||||||
self._shell("git --no-pager diff", check=False, cwd=root_path)
|
self._shell("git --no-pager diff", check=False, cwd=path)
|
||||||
if self._confirm(bail=False):
|
self._confirm()
|
||||||
|
|
||||||
if not self.commit_msg:
|
if not self.commit_msg:
|
||||||
self.commit_msg = self._message()
|
self.commit_msg = self._message()
|
||||||
self._shell("git add .", check=False, cwd=root_path)
|
|
||||||
self._shell(
|
self._shell("git add .", check=False, cwd=path)
|
||||||
f"git commit -vm '{self.commit_msg}'", check=False, cwd=root_path
|
self._shell(f"git commit -m '{self.commit_msg}'", check=False, cwd=path)
|
||||||
)
|
# self._shell("git push", check=False, cwd=path)
|
||||||
self._shell("git push", check=False, cwd=root_path)
|
|
||||||
|
|
||||||
def _validate(self):
|
def _validate(self):
|
||||||
if not hasattr(self, "GLOB"):
|
if not hasattr(self, "GLOB"):
|
||||||
@ -157,12 +158,12 @@ class Migration:
|
|||||||
output = self._shell(command, cwd=root_path)
|
output = self._shell(command, cwd=root_path)
|
||||||
if not output:
|
if not output:
|
||||||
self.log.info("No changes detected, moving on...")
|
self.log.info("No changes detected, moving on...")
|
||||||
return
|
return False
|
||||||
|
|
||||||
self.log.info(f"Diffing {root_path} ({idx+1}/{self.DIFF_LIMIT})")
|
self.log.info(f"Diffing {root_path} ({idx+1}/{self.DIFF_LIMIT})")
|
||||||
self._shell(command, check=False, cwd=root_path)
|
self._shell(command, check=False, cwd=root_path)
|
||||||
|
|
||||||
self._confirm()
|
return self._confirm()
|
||||||
|
|
||||||
def _clean(self, match=None, branch=False):
|
def _clean(self, match=None, branch=False):
|
||||||
if match:
|
if match:
|
||||||
@ -207,7 +208,6 @@ class Migration:
|
|||||||
|
|
||||||
contents = self.yaml.load(contents)
|
contents = self.yaml.load(contents)
|
||||||
|
|
||||||
original = contents.copy()
|
|
||||||
migrated = self.migrate(contents)
|
migrated = self.migrate(contents)
|
||||||
|
|
||||||
self.log.debug(f"Migrated {match}...")
|
self.log.debug(f"Migrated {match}...")
|
||||||
@ -218,17 +218,16 @@ class Migration:
|
|||||||
else:
|
else:
|
||||||
handle.write(migrated)
|
handle.write(migrated)
|
||||||
|
|
||||||
if idx < self.DIFF_LIMIT:
|
if idx <= self.DIFF_LIMIT:
|
||||||
self._diff(match, idx=idx, check=True)
|
if self._diff(match, idx=idx, check=True):
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
self.log.debug(f"Saved {match} back to the file system...")
|
self.log.debug(f"Saved {match} back to the file system...")
|
||||||
|
|
||||||
self.log.info("Finished migrating files...")
|
self.log.info("Finished migrating files...")
|
||||||
self.log.info("Commencing change commit run...")
|
self.log.info("Commencing change commit run...")
|
||||||
|
|
||||||
for path in self.paths:
|
self._commit()
|
||||||
self._commit(path)
|
|
||||||
|
|
||||||
self.log.info("Finished committing changes...")
|
self.log.info("Finished committing changes...")
|
||||||
self.log.info("Finished! May your tyops be ever glorious!")
|
self.log.info("Finished! May your tyops be ever glorious!")
|
||||||
|
Reference in New Issue
Block a user