Skip to content

Commit

Permalink
Merge 1efdc8d into c6cef5b
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Ruhs committed Jul 1, 2018
2 parents c6cef5b + 1efdc8d commit c956125
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/metadata.py
Expand Up @@ -2,7 +2,7 @@
{
'name': 'chroma-feedback',
'description': 'Turn your Razer keyboard, mouse or headphone into a extreme feedback device',
'version': '3.5.1',
'version': '3.6.0',
'license': 'GPL-3.0',
'keywords': 'razer chroma appveyor circle github gitlab jenkins teamcity travis ci',
'author': 'Henry Ruhs',
Expand Down
23 changes: 21 additions & 2 deletions src/provider/gitlab.py
Expand Up @@ -6,7 +6,25 @@ def fetch(host, slug, auth):
if host is None:
host = 'https://gitlab.com'
if slug and auth:
response = requests.get(host + '/api/v4/projects/' + slug + '/jobs', headers =
response = requests.get(host + '/api/v4/projects/' + slug + '/pipelines', headers =
{
'Private-Token': auth
})

# process response

if response and response.status_code == 200:
data = response.json()
pipeline = str(data[0]['id'])
if pipeline:
return fetch_jobs(host, slug, pipeline, auth)
return []


def fetch_jobs(host, slug, pipeline, auth):
response = None
if host and slug and pipeline and auth:
response = requests.get(host + '/api/v4/projects/' + slug + '/pipelines/' + pipeline + '/jobs', headers =
{
'Private-Token': auth
})
Expand All @@ -17,6 +35,7 @@ def fetch(host, slug, auth):
data = response.json()
result = []
for project in data:
project['slug'] = slug
result.extend(normalize_data(project))
return result
return []
Expand All @@ -27,7 +46,7 @@ def normalize_data(project):
[
{
'provider': 'gitlab',
'slug': project['user']['username'] + '/' + project['name'],
'slug': project['user']['username'] + '/' + project['slug'] + '/' + project['name'],
'active': True,
'status': normalize_status(project['status'])
}
Expand Down
2 changes: 1 addition & 1 deletion tests/provider/test_gitlab.py
Expand Up @@ -5,7 +5,7 @@

def test_fetch_user():
if 'GITLAB_TOKEN' in os.environ:
data = gitlab.fetch(None, '5583334', os.environ['GITLAB_TOKEN'])
data = gitlab.fetch(None, '7311836', os.environ['GITLAB_TOKEN'])
assert data[0]['provider'] == 'gitlab'
assert data[0]['active'] is True
assert data[0]['status']
Expand Down

0 comments on commit c956125

Please sign in to comment.