Skip to content

Commit c90c366

Browse files
authored
Merge pull request #78 from endlessm/wjt/push-vlxxxuyxmvpn
Don't set status if existing status is the same
2 parents 257240a + 87e5355 commit c90c366

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

godoctopus.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,27 @@ def set_status(
595595
head_sha: str,
596596
build_url: str,
597597
) -> bool:
598-
status: dict[str, str] = {
598+
new_status: dict[str, str] = {
599599
"state": "success",
600600
"description": STATUS_SUCCESS_DESCRIPTION,
601601
"context": STATUS_CONTEXT,
602602
"target_url": build_url,
603603
}
604-
response = api.session.post(f"{API}/repos/{repo}/statuses/{head_sha}", json=status)
604+
605+
for status in api.paginate(
606+
f"{API}/repos/{repo}/commits/{head_sha}/status",
607+
item_key="statuses",
608+
):
609+
if status["context"] == STATUS_CONTEXT:
610+
if all(status[k] == new_status[k] for k in new_status):
611+
return True
612+
# Otherwise, needs update
613+
break
614+
# If no existing status with the same context exists, we need to create one.
615+
616+
response = api.session.post(
617+
f"{API}/repos/{repo}/statuses/{head_sha}", json=new_status
618+
)
605619
if response.status_code == 403:
606620
logging.warning(
607621
"No permission to set commit status; "

0 commit comments

Comments
 (0)