Commit b9d93919 authored by Pietro Albini's avatar Pietro Albini

migrate to gitlab api v4

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