Commit 99bc9380 authored by Pietro Albini's avatar Pietro Albini

Provide the correct project ID to GitLab

parent 2a40fd4a
......@@ -24,7 +24,8 @@ class GitLabAPI:
self.manager = manager
self.url = manager.config["gitlab-url"]
self.token = manager.config["gitlab-token"]
self.project = manager.config["gitlab-project"].replace("/", "%2F")
self.project_name = manager.config["gitlab-project"]
self.project = self.project_id_of(self.project_name)
def call(self, method, endpoint, params=None, data=None):
"""Make a raw call to the GitLab API"""
......@@ -41,6 +42,15 @@ class GitLabAPI:
return response.json()
return False
def project_id_of(self, name):
"""Get the project ID of a specific project"""
projects = self.call("get", "projects")
for project in projects:
if project["path_with_namespace"] == name:
return project["id"]
raise NameError("No project named %s" % name)
def merge_requests(self):
"""Get all the merge requests of the project"""
return self.call("get", "projects/%s/merge_requests" % self.project, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment