Merge pull request #1300 from GLolol/plugindownloader-multibranch

Support non-master branches in PluginDownloader
This commit is contained in:
Valentin Lorentz 2017-09-17 10:10:04 +02:00 committed by GitHub
commit 4b37f91928

View File

@ -57,19 +57,21 @@ class GitRepository(VersionnedRepository):
pass pass
class GithubRepository(GitRepository): class GithubRepository(GitRepository):
def __init__(self, username, reponame, path='/'): def __init__(self, username, reponame, path='/', branch='master'):
self._username = username self._username = username
self._reponame = reponame self._reponame = reponame
self._branch = branch
if not path.startswith('/'): if not path.startswith('/'):
path = '/' + path path = '/' + path
if not path.endswith('/'): if not path.endswith('/'):
path += '/' path += '/'
self._path = path self._path = path
self._downloadUrl = 'https://github.com/%s/%s/tarball/master' % \ self._downloadUrl = 'https://github.com/%s/%s/tarball/%s' % \
( (
self._username, self._username,
self._reponame, self._reponame,
self._branch
) )
@ -81,13 +83,11 @@ class GithubRepository(GitRepository):
return json.loads(utils.web.getUrl(url).decode('utf8')) return json.loads(utils.web.getUrl(url).decode('utf8'))
def getPluginList(self): def getPluginList(self):
plugins = self._query( plugins = self._query('repos',
'repos', '%s/%s/contents%s' % (self._username,
'%s/%s/contents%s' % (
self._username,
self._reponame, self._reponame,
self._path, self._path),
) args={'ref': self._branch}
) )
if plugins is None: if plugins is None:
log.error(( log.error((
@ -111,6 +111,7 @@ class GithubRepository(GitRepository):
response.close() response.close()
fileObject.seek(0) fileObject.seek(0)
return tarfile.open(fileobj=fileObject, mode='r:gz') return tarfile.open(fileobj=fileObject, mode='r:gz')
def install(self, plugin): def install(self, plugin):
archive = self._download(plugin) archive = self._download(plugin)
prefix = archive.getnames()[0] prefix = archive.getnames()[0]
@ -292,6 +293,11 @@ repositories = utils.InsensitivePreservingDict({
'GLolol', 'GLolol',
'SupyPlugins', 'SupyPlugins',
), ),
'GLolol-py2legacy': GithubRepository(
'GLolol',
'SupyPlugins',
branch='python2-legacy'
),
'Iota': GithubRepository( 'Iota': GithubRepository(
'IotaSpencer', 'IotaSpencer',
'supyplugins', 'supyplugins',