Get on the right branch

This commit is contained in:
2024-05-14 17:17:51 -04:00
parent 9d78070c45
commit a3e195925a
2 changed files with 19 additions and 3 deletions
+18 -3
View File
@@ -5,6 +5,8 @@ from fastapi import FastAPI
from git import Repo
from nextcord.ext import commands
from config import DakinyConfig
app = FastAPI()
REPO_URL = "https://gitea.cheezers.org/imcompiling/dakiny-messages.git"
REPO_DIR = "./dakiny-messages"
@@ -13,7 +15,8 @@ REPO_DIR = "./dakiny-messages"
class ClanMessages(commands.Cog, name="Clan Messages"):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.clone_repo()
self.config: DakinyConfig = self.bot.config
self.repo_setup()
@commands.Cog.listener()
async def on_ready(self):
@@ -38,9 +41,8 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
# for ever directory, sort the files by number then post
# posting involves checking if there is a message for that particular file then editing it or creating a
# new one. the message could be deleted, which would cause a new message to be sent and database updated.
pass
def clone_repo(self):
def repo_setup(self):
"""
Checks if the repo exists and creates repo object, clones if it does not.
"""
@@ -50,6 +52,19 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
else:
self.repo = Repo.clone_from(REPO_URL, REPO_DIR)
self.origin = self.repo.remote("origin")
if self.config.params.git_branch == "test":
self.repo.create_head("test", self.origin.refs.test).set_tracking_branch(
self.origin.refs.test
).checkout()
else:
self.repo.create_head("main", self.origin.refs.main).set_tracking_branch(
self.origin.refs.main
).checkout()
self.origin.pull()
# This function will be called when this extension is loaded.
# It is necessary to add these functions to the bot.
+1
View File
@@ -23,6 +23,7 @@ class Params:
event_participate_points: int
event_post_channel_id: int
general_channel_id: int
git_branch: str
guild_id: int
high_council_role_id: int
voting_parent_id: int