Added /status command

This commit is contained in:
2025-04-28 13:06:55 +02:00
parent c96cb167b5
commit c4ebd1b891
6 changed files with 85 additions and 2 deletions

View File

@@ -9,5 +9,6 @@ from .autocomplete_utils import (
from .cache_utils import restore_from_cache
from .datetime_utils import get_unix_timestamp
from .event_utils import validate_event_validity
from .git_utils import get_current_commit
from .logging_utils import get_logger, get_logging_config
from .validation_utils import is_event_status_valid, is_operation_confirmed

View File

@@ -0,0 +1,27 @@
from pathlib import Path
import aiofiles
# TODO Add documentation
async def get_current_commit() -> str | None:
head_path: Path = Path(".git/HEAD")
if not head_path.exists():
return None
async with aiofiles.open(head_path, "r", encoding="utf-8") as head_file:
head_content: str = (await head_file.read()).strip()
if not head_content.startswith("ref:"):
return head_content
head_ref_path: Path = Path(".git/").joinpath(" ".join(head_content.split(" ")[1:]))
if not head_ref_path.exists():
return None
async with aiofiles.open(head_ref_path, "r", encoding="utf-8") as head_ref_file:
head_ref_content: str = (await head_ref_file.read()).strip()
return head_ref_content