Commit 844ed2ce authored by Simon Chabot's avatar Simon Chabot
Browse files

feat: assignbot choose a reviewer and not an assignee

closes #4
parent 81b0ec1b37cf
Pipeline #43504 passed with stage
in 43 seconds
...@@ -132,7 +132,7 @@ class ReviewAssigner: ...@@ -132,7 +132,7 @@ class ReviewAssigner:
try: try:
self.cnx.http_put( self.cnx.http_put(
f"/projects/{merge_request.project_id}/merge_requests/{merge_request.iid}", f"/projects/{merge_request.project_id}/merge_requests/{merge_request.iid}",
query_data={"assignee_id": user.id}, query_data={"reviewer_id": user.id},
) )
except GitlabHttpError: except GitlabHttpError:
print( print(
...@@ -148,13 +148,13 @@ class ReviewAssigner: ...@@ -148,13 +148,13 @@ class ReviewAssigner:
) )
print(f"{user.name} has been assigned to {merge_request.title}") print(f"{user.name} has been assigned to {merge_request.title}")
def _all_reviews(self, assignee_id="None"): def _all_reviews(self, reviewer_id="None"):
merge_requests = self.cnx.mergerequests.list( merge_requests = self.cnx.mergerequests.list(
labels=TO_REVIEW_LABEL, labels=TO_REVIEW_LABEL,
state="opened", state="opened",
wip="no", wip="no",
scope="all", scope="all",
assignee_id=assignee_id, reviewer_id=reviewer_id,
all=True, all=True,
) )
...@@ -164,7 +164,7 @@ class ReviewAssigner: ...@@ -164,7 +164,7 @@ class ReviewAssigner:
state="opened", state="opened",
wip="no", wip="no",
scope="all", scope="all",
assignee_id=assignee_id, reviewer_id=reviewer_id,
all=True, all=True,
) )
) )
...@@ -190,11 +190,11 @@ class ReviewAssigner: ...@@ -190,11 +190,11 @@ class ReviewAssigner:
yield merge_request yield merge_request
def all_reviews_to_do(self): def all_reviews_to_do(self):
return self._all_reviews(assignee_id="None") return self._all_reviews(reviewer_id="None")
def all_pending_reviews_older_than(self, older_than): def all_pending_reviews_older_than(self, older_than):
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
for mr in self._all_reviews(assignee_id="Any"): for mr in self._all_reviews(reviewer_id="Any"):
mr_last_update = datetime.fromisoformat( mr_last_update = datetime.fromisoformat(
mr.updated_at.replace("Z", "+00:00") mr.updated_at.replace("Z", "+00:00")
) )
......
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