~sourcemage/wand

48218ab4a1d5f50803e75e216e8b33c1a9c5f13d — Vlad Glagolev 3 years ago 61ef628
Add absolute path support; check paths at config stage; fix repo config checks
2 files changed, 38 insertions(+), 31 deletions(-)

M remirror/remirror
M remirror/remirror.config.yaml
M remirror/remirror => remirror/remirror +19 -12
@@ 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')

M remirror/remirror.config.yaml => remirror/remirror.config.yaml +19 -19
@@ 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