diff options
author | Vlad Glagolev | 2020-05-30 19:28:05 +0000 |
---|---|---|
committer | Vlad Glagolev | 2020-05-30 19:28:05 +0000 |
commit | 48218ab4a1d5f50803e75e216e8b33c1a9c5f13d (patch) | |
tree | 61c63464a5fa9a04d725864c11cb1b469b34bbe6 | |
parent | 61ef62848d9888ed9824046abb0a5c67f24725cb (diff) |
Add absolute path support; check paths at config stage; fix repo config checks
-rwxr-xr-x | remirror/remirror | 31 | ||||
-rw-r--r-- | remirror/remirror.config.yaml | 38 |
2 files changed, 38 insertions, 31 deletions
diff --git a/remirror/remirror b/remirror/remirror index f0f629b..ada46cd 100755 --- a/remirror/remirror +++ b/remirror/remirror @@ -37,7 +37,7 @@ except ImportError: HAS_REQUESTS = False -__version__ = "0.0.3" # major.minor.revision +__version__ = "0.0.4" # major.minor.revision # ~/.sourcemage/mirror.yaml @@ -52,7 +52,7 @@ _CONFIG_FORMAT = { PROVIDERS = { 'github': 'ProviderGitHub', 'bitbucket': 'ProviderBitbucket', - 'sourcehut': 'ProviderSourcehut' + 'sourcehut': 'ProviderSourceHut' } @@ -82,6 +82,11 @@ def configure(fp): except yaml.YAMLError as e: ConfigError("syntax mismatch in configuration file '%s': %s" % (fp.name, e)) + try: + root = config['root'] + except KeyError as e: + ConfigError("missing section: %s" % e) + # should be replaced with schema (https://github.com/keleshev/schema) for section in _CONFIG_FORMAT: if section not in config: @@ -105,8 +110,16 @@ def configure(fp): ConfigError("repository item must be a dictionary") for k, v in repo.items(): - if (type(k) and type(v)) != str: + if type(k) != str or type(v) != str: ConfigError("key/value types must be strings") + + fullpath = v if os.path.isabs(v) else os.path.join(root, v) + + if os.path.isdir(fullpath): + # overwrite with full path value + repo[k] = fullpath + else: + ConfigError("repository path '%s' doesn't exist" % k) else: if type(item[key]) != str: ConfigError("value for '%s' must be a string" % key) @@ -136,17 +149,11 @@ class ReMirror(Process): class Repo(object): def __init__(self, repo, project, conf): - self.name = repo[0] - self.fullpath = os.path.join(conf['root'], repo[1] + '.git') + self.name, self.fullpath = repo self.project = project self.conf = conf def sync(self): - if not os.path.isdir(self.fullpath): - self.error("'%s' repository doesn't exist, skipping" % self.fullpath) - - return - for p_conf in self.conf['mirrors']: p_name = p_conf['name'].lower() @@ -322,12 +329,12 @@ class ProviderBitbucket(Provider): req.raise_for_status() -class ProviderSourcehut(Provider): +class ProviderSourceHut(Provider): api_url = "https://git.sr.ht/api/" git_host = "git@git.sr.ht" def __init__(self, conf): - super(ProviderSourcehut, self).__init__(conf) + super(ProviderSourceHut, self).__init__(conf) self.auth = {'headers': {"Authorization": "token %s" % self.conf['token']}} self.group = '~' + self.conf.get('organization') diff --git a/remirror/remirror.config.yaml b/remirror/remirror.config.yaml index 1809d35..870a348 100644 --- a/remirror/remirror.config.yaml +++ b/remirror/remirror.config.yaml @@ -7,45 +7,45 @@ projects: - name: Codex key: SMCDX repos: - - grimoire: grimoire - - grimoire-xorg-modular: grimoire/xorg-modular - - grimoire-z-rejected: grimoire/z-rejected - - grimoire-games: grimoire/games - - grimoire-binary: grimoire/binary - - grimoire-p4_history: grimoire/grimoire-p4_history + - grimoire: grimoire.git + - grimoire-xorg-modular: grimoire/xorg-modular.git + - grimoire-z-rejected: grimoire/z-rejected.git + - grimoire-games: grimoire/games.git + - grimoire-binary: grimoire/binary.git + - grimoire-p4_history: grimoire/grimoire-p4_history.git - name: Cauldron key: SMCLD repos: - - cauldron: cauldron + - cauldron: cauldron.git - name: Tome key: SMTM repos: - - tome-rdp: tome/rdp - - tome-scrolls: tome/scrolls + - tome-rdp: tome/rdp.git + - tome-scrolls: tome/scrolls.git - name: Sorcery key: SMSRC repos: - - sorcery: sorcery + - sorcery: sorcery.git - name: Wand key: SMWND repos: - - wand: wand + - wand: wand.git - name: Miscellaneous key: SMMSC repos: - - archspecs: misc/archspecs - - bashdoc: misc/bashdoc - - castfs: misc/castfs - - enthrall: misc/enthrall - - guru-tools: misc/guru-tools - - licenses: misc/licenses - - quill: misc/quill - - prometheus: misc/prometheus + - archspecs: misc/archspecs.git + - bashdoc: misc/bashdoc.git + - castfs: misc/castfs.git + - enthrall: misc/enthrall.git + - guru-tools: misc/guru-tools.git + - licenses: misc/licenses.git + - quill: misc/quill.git + - prometheus: misc/prometheus.git mirrors: - name: github |