From adad8eea2dc62b09d08a3f383b1f0cd9e20d89bc Mon Sep 17 00:00:00 2001 From: Noelle Wang <73260931+No767@users.noreply.github.com> Date: Tue, 28 May 2024 18:37:23 -0700 Subject: [PATCH] Fix pygit2 deprecations (#127) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- bot/cogs/utilities.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 44d1c9d..d269481 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.11 + python: python3.12 files: '.py' exclude: ".env,.yml,.gitignore,.git,.md,.txt" default_stages: [push, commit] diff --git a/bot/cogs/utilities.py b/bot/cogs/utilities.py index 5aa76db..b8ac680 100644 --- a/bot/cogs/utilities.py +++ b/bot/cogs/utilities.py @@ -32,7 +32,7 @@ def get_bot_uptime(self, *, brief: bool = False) -> str: def format_commit(self, commit: pygit2.Commit) -> str: short, _, _ = commit.message.partition("\n") - short_sha2 = commit.hex[0:6] + short_sha2 = str(commit.id)[0:6] commit_tz = datetime.timezone( datetime.timedelta(minutes=commit.commit_time_offset) ) @@ -42,7 +42,8 @@ def format_commit(self, commit: pygit2.Commit) -> str: # [`hash`](url) message (offset) offset = format_dt(commit_time.astimezone(datetime.timezone.utc), "R") - return f"[`{short_sha2}`](https://github.com/transprogrammer/rodhaj/commit/{commit.hex}) {short} ({offset})" + commit_id = str(commit.id) + return f"[`{short_sha2}`](https://github.com/transprogrammer/rodhaj/commit/{commit_id}) {short} ({offset})" def get_last_commits(self, count: int = 5): repo = pygit2.Repository(".git")