Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architecture / untangling #351

Open
tony opened this issue Mar 4, 2022 · 0 comments
Open

Architecture / untangling #351

tony opened this issue Mar 4, 2022 · 0 comments

Comments

@tony
Copy link
Member

tony commented Mar 4, 2022

The hackable repo manager, built on libvcs. With great defaults, and presets if those don't work

Config Loaders and backends

Finds configs (based on template loaders in django) and processes them them

  • Loader: Searches
  • Backend: Parser, e.g. yaml, json, toml, ini, python
CONFIG_LOADERS = [
    {
        "BACKEND": "vcspull.configs.loaders.json.JSONLoader",
        "XDG_DIRS": True,
        # optionally
        "DIRS": [
            "/custom/lookup/path",
        ],
    },
    {"BACKEND": "vcspull.configs.loaders.json.YAMLLoader", "XDG_DIRS": True},
    {"BACKEND": "vcspull.configs.loaders.json.TOMLLoader", "XDG_DIRS": True},
    {"BACKEND": "vcspull.configs.loaders.json.PythonLoader", "XDG_DIRS": True},
]

Config processors

(inspired by context processors / middleware):

helpers that expand config, e.g.

repo: 'git+https://github.com/vcs-python/vcspull'
repo:
  remotes:
    origin:
      push: 'git+https://github.com/vcs-python/vcspull'
      pull: 'git+https://github.com/vcs-python/vcspull'
CONFIG_PROCESSORS = [
    # before:
    #   repo: 'git+https://github.com/vcs-python/vcspull'
    # after:
    #   repo:
    #     remotes:
    #        origin:
    #          push: 'git+https://github.com/vcs-python/vcspull'
    #          pull: 'git+https://github.com/vcs-python/vcspull'
    "vcspull.configs.processors.simple_repo",
    # before:
    #  repo:
    #    origin: 'git+https://github.com/vcs-python/vcspull'
    # after:
    #  repo:
    #     origin:
    #      push: 'git+https://github.com/vcs-python/vcspull'
    #      pull: 'git+https://github.com/vcs-python/vcspull'
    "vcspull.configs.processors.simple_remote",
]

URL Parsers / adapters

e.g. pip, npm/yarn, normal vcs URLs

Merge / conflict resolutions

Function to handle merge behavior when same repo name exists. `

'MERGE_BEHAVIOR: 'vcspull.config.merge.default'

default = deep_extend

def overwrite(a, b, config_a, config_b):
    return b

def extend(a, b, config_a, config_b):
    a.extend(b)

def deep_extend(a, b, config_a, config_b):
    # deep merge code

above: hopefully if we pass config_a and config_b, if at all, they'd be immutable

see:https://github.com/TehShrike/deepmerge#custommerge

VCS backends

VCS_BACKENDS = {
    'git': 'libvcs.git.Git',
    'svn': 'libvcs.svn.Svn'
    'hg': 'libvcs.hg.Mercurial'
}

Allows people to override with custom behavior, esp. overriding sync()

Initialization

vcspull settings:

{
  "extends": "vcspull.settings.default",
  "CONFIG_LOADERS": [],
  "CONFIG_PROCESSORS": []
}

Consider a json wrapper for jsonc

Strip removing trailing commas and comments

VCSPull(settings='str_or_dict', init=True)

vp = VCSPull(settings='vcspull.config.default')
vp = VCSPull(settings='~/.config/vcspull/settings.py')
vp = VCSPull(settings='~/.config/vcspull/settings.json')

Without initializing / finding configs:

vp = VCSPull(settings='~/.config/vcspull/settings.json', init=False)

vp.settings
vp.init()  # Finds configs via loaders, parses via backends, builds index of repos
@tony tony changed the title Architecture Architecture / untangling Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant