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