CLI 0.2.0/git number for admins

This commit is contained in:
Vladless
2025-06-14 05:13:20 +03:00
parent 973436167b
commit 902a051dc1
2 changed files with 21 additions and 9 deletions
+17 -6
View File
@@ -23,10 +23,6 @@ def get_git_commit_number() -> str:
repo_url = "https://github.com/Vladless/Solo_bot"
try:
current_branch = subprocess.check_output(
["git", "rev-parse", "--abbrev-ref", "HEAD"]
).decode().strip()
local_number = subprocess.check_output(
["git", "rev-list", "--count", "HEAD"]
).decode().strip()
@@ -34,12 +30,27 @@ def get_git_commit_number() -> str:
local_hash = subprocess.check_output(
["git", "rev-parse", "HEAD"]
).decode().strip()
try:
branch = subprocess.check_output(
["git", "rev-parse", "--abbrev-ref", "HEAD"]
).decode().strip()
if branch == "HEAD":
describe = subprocess.check_output(["git", "describe", "--tags", "--exact-match"], stderr=subprocess.DEVNULL).decode().strip()
if describe.startswith("v") or "release" in describe.lower():
branch = "main"
else:
branch = "dev"
except Exception:
branch = "dev"
except Exception:
return "\n(Требуется обновление через CLI)"
try:
remote_commit = subprocess.check_output(
["git", "ls-remote", "origin", f"refs/heads/{current_branch}"]
["git", "ls-remote", "origin", f"refs/heads/{branch}"]
).decode()
remote_hash = remote_commit.split()[0]
@@ -170,4 +181,4 @@ async def errors_handler(event: ErrorEvent, bot: Bot) -> bool:
except Exception as exception:
logger.error(f"Неожиданная ошибка в error handler: {exception}")
return True
return True
+4 -3
View File
@@ -228,7 +228,8 @@ def update_from_beta():
os.chdir(PROJECT_DIR)
console.print("[cyan]📅 Клонируем временный репозиторий...[/cyan]")
subprocess.run(["rm", "-rf", TEMP_DIR])
if os.system(f"git clone -b dev {GITHUB_REPO} {TEMP_DIR}") != 0:
if os.system(f"git clone --depth=1000000 -b dev {GITHUB_REPO} {TEMP_DIR}") != 0:
console.print("[red]❌ Ошибка при клонировании. Обновление отменено.[/red]")
return
@@ -301,7 +302,7 @@ def update_from_release():
console.print(f"[cyan]📥 Клонируем релиз {tag_name} во временную папку...[/cyan]")
subprocess.run(["rm", "-rf", TEMP_DIR])
subprocess.run(
f"git clone --depth 1 --branch {tag_name} {GITHUB_REPO} {TEMP_DIR}",
f"git clone --branch {tag_name} {GITHUB_REPO} {TEMP_DIR}",
shell=True,
check=True,
)
@@ -358,7 +359,7 @@ def show_update_menu():
def show_menu():
table = Table(
title="Solobot CLI v0.1.9", title_style="bold magenta", header_style="bold blue"
title="Solobot CLI v0.2.0", title_style="bold magenta", header_style="bold blue"
)
table.add_column("", justify="center", style="cyan", no_wrap=True)
table.add_column("Операция", style="white")