Automate your mass typo updates
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decentral1se 0610f89da6
Default to not pulling for now
3 months ago
README.md Further docs 3 months ago
requirements.txt Add reqs 3 months ago
tyop.py Default to not pulling for now 3 months ago

README.md

tyop

WARNING: still in prototype stage...

Automate your mass typo updates.

Run/Hack

$ python3 -m venv .venv && source .venv/bin/activate 
$ pip install -r requirements.txt
$ python mymigration.py --yaml

CLI

  • --reset: run git-checkout on all of your glob matches and exit
  • --validate: ensure your Migration sub-class is valid
  • --yaml: tell tyop that it should try to load the YAML with ruamel.yaml
  • --debug: enable debug logging

Logic

  • Match all files specified by the GLOB pattern and apply the following
    • Check out main/master, git-pull and git-checkout for clean branch
    • Feed matched file contents into Migration sub-class and show the diff
    • Show a few diffs to make sure things are running smoothly and then apply to all matches
    • Iterate through all matches and git-commit/git-push changes (Use s to skip changes)

Example migration

from tyop import Migration


class InternalTrueMigration(Migration):
    GLOB = "~/.abra/apps/**/compose*.yml"

    def migrate(self, compose):
        try:
            if "internal" in compose["networks"]:
                compose["networks"]["internal"] = {"internal": True}
            return compose
        except Exception:
            return compose


InternalTrueMigration()