diff options
author | Vlad Glagolev | 2020-05-23 18:11:13 +0000 |
---|---|---|
committer | Vlad Glagolev | 2020-05-23 18:11:13 +0000 |
commit | 61ef62848d9888ed9824046abb0a5c67f24725cb (patch) | |
tree | 1575570399aee099cf960a71b708f99eaad800e2 | |
parent | 83fe0e95eaafa5bfec7514c189d9a8e972a9c10a (diff) |
Sourcehut: switch to API calls
-rwxr-xr-x | remirror/remirror | 15 | ||||
-rw-r--r-- | remirror/remirror.config.yaml | 1 |
2 files changed, 5 insertions, 11 deletions
diff --git a/remirror/remirror b/remirror/remirror index 213b1ce..f0f629b 100755 --- a/remirror/remirror +++ b/remirror/remirror @@ -37,7 +37,7 @@ except ImportError: HAS_REQUESTS = False -__version__ = "0.0.2" # major.minor.revision +__version__ = "0.0.3" # major.minor.revision # ~/.sourcemage/mirror.yaml @@ -46,7 +46,7 @@ _DEFAULT_CONFIG = os.path.join(os.path.expanduser("~"), ".sourcemage/mirror.yaml _CONFIG_FORMAT = { 'root': '', 'projects': ('name', 'repos'), - 'mirrors': ('name', 'username') + 'mirrors': ('name', 'username', 'token') } PROVIDERS = { @@ -324,28 +324,21 @@ class ProviderBitbucket(Provider): class ProviderSourcehut(Provider): api_url = "https://git.sr.ht/api/" - web_url = "https://git.sr.ht/" git_host = "git@git.sr.ht" def __init__(self, conf): super(ProviderSourcehut, self).__init__(conf) + self.auth = {'headers': {"Authorization": "token %s" % self.conf['token']}} self.group = '~' + self.conf.get('organization') def sanity_check(self, repo): - repo_ok = "/{0}/{1}/".format(self.group, repo.name) + repo_ok = "/{0}/repos/{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 38e6b2f..1809d35 100644 --- a/remirror/remirror.config.yaml +++ b/remirror/remirror.config.yaml @@ -60,4 +60,5 @@ mirrors: - name: sourcehut username: magesync + token: secret organization: sourcemage |