Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master wand by Vlad Glagolev (83fe0e95eaafa5bfec7514c189d9a8e972a9c10a)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Vlad Glagolev <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master wand by Vlad Glagolev (83fe0e95eaafa5bfec7514c189d9a8e972a9c10a)
  • Date: Thu, 21 May 2020 02:07:42 +0000

GIT changes to master wand by Vlad Glagolev <stealth AT sourcemage.org>:

remirror/remirror | 64
++++++++++++++++++++++++++++++++++--------
remirror/remirror.config.yaml | 5 ++-
2 files changed, 56 insertions(+), 13 deletions(-)

New commits:
commit 83fe0e95eaafa5bfec7514c189d9a8e972a9c10a
Author: Vlad Glagolev <stealth AT sourcemage.org>
Commit: Vlad Glagolev <stealth AT sourcemage.org>

Add Sourcehut support

diff --git a/remirror/remirror b/remirror/remirror
index 0745e09..213b1ce 100755
--- a/remirror/remirror
+++ b/remirror/remirror
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# (c) 2017-2018, Vlad Glagolev <stealth AT sourcemage.org>
+# (c) 2017-2020, Vlad Glagolev <stealth AT sourcemage.org>

import argparse
import os
@@ -37,7 +37,7 @@ except ImportError:
HAS_REQUESTS = False


-__version__ = "0.0.1" # major.minor.revision
+__version__ = "0.0.2" # major.minor.revision


# ~/.sourcemage/mirror.yaml
@@ -46,7 +46,13 @@ _DEFAULT_CONFIG = os.path.join(os.path.expanduser("~"),
".sourcemage/mirror.yaml
_CONFIG_FORMAT = {
'root': '',
'projects': ('name', 'repos'),
- 'mirrors': ('name', 'username', 'token')
+ 'mirrors': ('name', 'username')
+}
+
+PROVIDERS = {
+ 'github': 'ProviderGitHub',
+ 'bitbucket': 'ProviderBitbucket',
+ 'sourcehut': 'ProviderSourcehut'
}


@@ -136,21 +142,27 @@ class Repo(object):
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()

- if p_name == "github":
- provider = ProviderGitHub(p_conf)
- elif p_name == "bitbucket":
- provider = ProviderBitbucket(p_conf)
- else:
+ provider = PROVIDERS.get(p_name)
+
+ if provider is None:
provider = Provider(p_conf)

provider.log("unsupported mirror provider detected: '%s'" %
p_name)

continue
+ else:
+ globals()[provider](p_conf).mirror(self)

- provider.mirror(self)
+ def error(self, message):
+ sys.stderr.write("Error: %s\n" % message)


class Provider(object):
@@ -194,7 +206,12 @@ class Provider(object):
return req

def push(self, repo):
- git_repo = "%s:%s/%s.git" % (self.git_host, self.group, repo.name)
+ # special case for sourcehut:
+ if self.group.startswith('~'):
+ git_repo = "%s:%s/%s" % (self.git_host, self.group, repo.name)
+ else:
+ git_repo = "%s:%s/%s.git" % (self.git_host, self.group,
repo.name)
+
git_cmd = "git push --mirror %s" % git_repo

sub_cmd = shlex.split(git_cmd)
@@ -223,8 +240,6 @@ class Provider(object):
def error(self, message):
sys.stderr.write("Error: %s\n" % message)

- return
-

class ProviderGitHub(Provider):
api_url = "https://api.github.com/";
@@ -307,6 +322,31 @@ class ProviderBitbucket(Provider):
req.raise_for_status()


+class ProviderSourcehut(Provider):
+ api_url = "https://git.sr.ht/api/";
+ web_url = "https://git.sr.ht/";
+ git_host = "git AT git.sr.ht"
+
+ def __init__(self, conf):
+ super(ProviderSourcehut, self).__init__(conf)
+
+ self.group = '~' + self.conf.get('organization')
+
+ def sanity_check(self, repo):
+ repo_ok = "/{0}/{1}/".format(self.group, repo.name)
+
+ req = self.http_call(repo_ok)
+
+ req.raise_for_status()
+
+ def http_call(self, url):
+ req_url = self.web_url + url.lstrip('/')
+
+ req = requests.get(req_url)
+
+ return req
+
+
def mirror(conf):
queue = Queue()

diff --git a/remirror/remirror.config.yaml b/remirror/remirror.config.yaml
index 21edb07..38e6b2f 100644
--- a/remirror/remirror.config.yaml
+++ b/remirror/remirror.config.yaml
@@ -57,4 +57,7 @@ mirrors:
- name: bitbucket
username: magesync
token: secret
- team: sourcemage
+
+ - name: sourcehut
+ username: magesync
+ organization: sourcemage



  • [SM-Commit] GIT changes to master wand by Vlad Glagolev (83fe0e95eaafa5bfec7514c189d9a8e972a9c10a), Vlad Glagolev, 05/20/2020

Archive powered by MHonArc 2.6.24.

Top of Page