From 58b230afe6ec944102c3ef69d1c198037aca0a73 Mon Sep 17 00:00:00 2001 From: imcompiling Date: Tue, 27 May 2025 23:31:02 -0400 Subject: [PATCH] Fix: Catch git error and refresh connection. I think that the git error is just happening from timing out. Trying to fix by refreshing the connection when it happens. --- dakiny_bot/cogs/clan_messages/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dakiny_bot/cogs/clan_messages/__init__.py b/dakiny_bot/cogs/clan_messages/__init__.py index bd1e1f6..e2f9469 100644 --- a/dakiny_bot/cogs/clan_messages/__init__.py +++ b/dakiny_bot/cogs/clan_messages/__init__.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING import uvicorn from fastapi import FastAPI from git import Repo +from git.exc import GitCommandError from nextcord.ext import commands from dakiny_bot.classes.gitea_webhook import GiteaWebhook @@ -55,7 +56,11 @@ class ClanMessages(commands.Cog, name="Clan Messages"): template_updates = {file.split("/")[1] for file in modified_files if "message_templates" in file} channel_updates = {file.split("/")[1] for file in modified_files if file.split("/")[1] not in template_updates} - self.origin.pull() + try: + self.origin.pull() + except GitCommandError: + # I think the git connection timed out. Get a new one. + self.repo_setup() guild: nextcord.Guild = self.bot.get_guild(settings.params.guild_id) await update_clan_messages(guild, channel_updates)