Skip to content

Commit

Permalink
Merge pull request #56778 from ClickHouse/fix-pygithub
Browse files Browse the repository at this point in the history
Fix pygithub
  • Loading branch information
Felixoid committed Nov 15, 2023
2 parents 4b7c80d + 30c6cea commit 89dd479
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions tests/ci/cherry_pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,18 @@ def ping_cherry_pick_assignees(self, dry_run: bool) -> None:
self.cherrypick_pr.number,
)
# The `updated_at` is Optional[datetime]
cherrypick_updated_at = self.cherrypick_pr.updated_at or datetime.now()
since_updated = datetime.now() - cherrypick_updated_at
cherrypick_updated_ts = (
self.cherrypick_pr.updated_at or datetime.now()
).timestamp()
since_updated = int(datetime.now().timestamp() - cherrypick_updated_ts)
since_updated_str = (
f"{since_updated.days}d{since_updated.seconds // 3600}"
f"h{since_updated.seconds // 60 % 60}m{since_updated.seconds % 60}s"
f"{since_updated // 86400}d{since_updated // 3600}"
f"h{since_updated // 60 % 60}m{since_updated % 60}s"
)
if since_updated < timedelta(days=1):
if since_updated < 86400:
logging.info(
"The cherry-pick PR was updated at %s %s ago, "
"The cherry-pick PR was updated %s ago, "
"waiting for the next running",
cherrypick_updated_at.isoformat(),
since_updated_str,
)
return
Expand Down
8 changes: 4 additions & 4 deletions tests/ci/merge_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def is_approved(self, team: List[NamedUser]) -> bool:
logging.info("The PR is changed at %s", last_changed.isoformat())

approved_at = max(review.submitted_at for review in approved.values())
if approved_at == datetime.fromtimestamp(0):
if approved_at.timestamp() == 0:
logging.info(
"Unable to get `datetime.fromtimestamp(0)`, "
"here's debug info about reviews: %s",
Expand All @@ -138,7 +138,7 @@ def is_approved(self, team: List[NamedUser]) -> bool:
else:
logging.info("The PR is approved at %s", approved_at.isoformat())

if approved_at < last_changed:
if approved_at.timestamp() < last_changed.timestamp():
logging.info(
"There are changes done at %s after approval at %s",
last_changed.isoformat(),
Expand Down Expand Up @@ -230,8 +230,8 @@ def main():
# An ugly and not nice fix to patch the wrong organization URL,
# see https://github.com/PyGithub/PyGithub/issues/2395#issuecomment-1378629710
# pylint: disable=protected-access
repo.organization._url.value = repo.organization.url.replace( # type: ignore
"/users/", "/orgs/", 1
repo.organization._url = repo._makeStringAttribute(
repo.organization.url.replace("/users/", "/orgs/", 1)
)
# pylint: enable=protected-access
pr = repo.get_pull(args.pr)
Expand Down

0 comments on commit 89dd479

Please sign in to comment.