feat: now you can see version if module updated

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-24 20:56:58 +03:00
parent db62a5aee1
commit 74638c14d0

View File

@@ -5,6 +5,7 @@ import subprocess
import os import os
import tempfile import tempfile
from pathlib import Path from pathlib import Path
import ast
import parse import parse
@@ -131,6 +132,21 @@ def get_module_developer(file_path):
return None return None
def _parse_version_from_source(source: str):
try:
tree = ast.parse(source)
except SyntaxError:
return None
for node in tree.body:
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id == "__version__":
try:
return ast.literal_eval(node.value)
except (ValueError, SyntaxError):
return None
def is_module_file(file_path): def is_module_file(file_path):
"""Check if file is a Python module in a modules directory""" """Check if file is a Python module in a modules directory"""
@@ -271,8 +287,18 @@ async def main():
except Exception: except Exception:
old_hash = arguments.base_commit old_hash = arguments.base_commit
version = ""
try:
with open(file_path, 'r', encoding='utf-8') as f:
source = f.read()
version_tuple = _parse_version_from_source(source)
if version_tuple:
version = '.'.join(map(str, version_tuple))
except Exception as e:
print(f"Error parsing version from {file_path}: {e}")
diff_url = f"https://github.com/MuRuLOSE/limoka/compare/{old_hash}...{new_hash}.diff" diff_url = f"https://github.com/MuRuLOSE/limoka/compare/{old_hash}...{new_hash}.diff"
title = f"🪼 <b>Module <code>{module_name}</code> changes approved</b>" title = f"🪼 <b>Module <code>{module_name}</code> <code>{version}</code> changes approved</b>"
if developer: if developer:
title += f"\nby <code>{developer}</code>" title += f"\nby <code>{developer}</code>"