Commit 79ce1e37 authored by Simon Chabot's avatar Simon Chabot
Browse files

feat: assignbot choose a reviewer and not an assignee

closes #4
parent 7817307e003a
...@@ -47,13 +47,13 @@ Do you think it should still be merged? ...@@ -47,13 +47,13 @@ Do you think it should still be merged?
Thank you for your time. Thank you for your time.
""" """
def all_reviews(cnx, assignee_id="None"): def all_reviews(cnx, reviewer_id="None"):
merge_requests = cnx.mergerequests.list( merge_requests = 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,
) )
...@@ -63,7 +63,7 @@ def all_reviews(cnx, assignee_id="None"): ...@@ -63,7 +63,7 @@ def all_reviews(cnx, assignee_id="None"):
state="opened", state="opened",
wip="no", wip="no",
scope="all", scope="all",
assignee_id=assignee_id, reviewer_id=reviewer_id,
all=True, all=True,
) )
) )
...@@ -173,7 +173,7 @@ class ReviewAssigner: ...@@ -173,7 +173,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_ids": [user.id]},
) )
except GitlabHttpError: except GitlabHttpError:
print( print(
...@@ -189,13 +189,12 @@ class ReviewAssigner: ...@@ -189,13 +189,12 @@ 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_to_do(self): def all_reviews_to_do(self):
return all_reviews(self.cnx, assignee_id="None") return all_reviews(self.cnx, 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 all_reviews(self.cnx, assignee_id="Any"): for mr in all_reviews(self.cnx, 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