Commit b9d93919 authored by Pietro Albini's avatar Pietro Albini

migrate to gitlab api v4

parent b7467053
......@@ -77,8 +77,8 @@ class TestsManager:
if new is None:
raise RuntimeError("Can't get merge requests from GitLab!")
for request in new:
add(request["source_branch"], request["id"])
self.details["branches"][name] = request["id"]
add(request["source_branch"], request["iid"])
self.details["branches"][request["source_branch"]] = request["iid"]
self.save_details()
......@@ -178,7 +178,7 @@ class TestsManager:
# The instance should be created
elif branch not in self.branches and obj["state"] == "opened":
self.branches[branch] = branches.Branch(self, branch, obj["id"])
self.branches[branch] = branches.Branch(self, branch, obj["iid"])
self.branches[branch].deploy()
self.instances.load_branch(self.branches[branch])
......
......@@ -31,8 +31,8 @@ class Branch:
self.manager = manager
self.name = name
self.mr = merge_request
self.mr_id = None
self.mr = None
self.mr_id = merge_request
self.mr_url = None
self.author = None
self.author_url = None
......@@ -53,13 +53,13 @@ class Branch:
self.active = True
return
result = self.manager.gitlab.merge_request(self.mr)
result = self.manager.gitlab.merge_request(self.mr_id)
if result:
active = result["state"] == "opened"
else:
active = False
self.active = active
self.mr_id = result["iid"]
self.mr = result["id"]
self.mr_url = (self.manager.config["gitlab-url"]+"/"+
self.manager.config["gitlab-project"]+
"/merge_requests/"+str(self.mr_id))
......
......@@ -34,7 +34,7 @@ class GitLabAPI:
if data is None:
data = {}
url = self.url+"/api/v3/"+endpoint
url = self.url+"/api/v4/"+endpoint
params["private_token"] = self.token
response = requests.request(method, url, params=params, data=data)
......@@ -59,12 +59,12 @@ class GitLabAPI:
def merge_request(self, id):
"""Get a single merge request on the project"""
return self.call("get", "projects/%s/merge_request/%s" % (
return self.call("get", "projects/%s/merge_requests/%s" % (
self.project, id))
def post_comment(self, id, text):
"""Post a comment on a merge request"""
return self.call("post", "projects/%s/merge_request/%s/comments" % (
return self.call("post", "projects/%s/merge_requests/%s/comments" % (
self.project, id), data={"note": text})
def commit_status(self, commit, state, ref, url=None):
......
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