Merge branch 'main' of https://floke-gitea.duckdns.org/Floke/Brancheneinstufung2
This commit is contained in:
@@ -9,7 +9,7 @@ import subprocess
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
try:
|
||||
from dev_session import add_comment_to_notion_task, decimal_hours_to_hhmm
|
||||
from dev_session import append_blocks_to_notion_page, decimal_hours_to_hhmm
|
||||
from datetime import datetime
|
||||
except ImportError:
|
||||
print("Fehler: Konnte dev_session.py nicht importieren.", file=sys.stderr)
|
||||
@@ -21,7 +21,6 @@ SESSION_FILE_PATH = os.path.join(SESSION_DIR, "SESSION_INFO")
|
||||
def get_last_commit_message() -> str:
|
||||
"""Holt die letzte Commit-Nachricht mit git."""
|
||||
try:
|
||||
# Führt 'git log -1 --pretty=%B' aus, um die vollständige Commit-Nachricht zu erhalten
|
||||
result = subprocess.run(
|
||||
["git", "log", "-1", "--pretty=%B"],
|
||||
capture_output=True,
|
||||
@@ -34,7 +33,6 @@ def get_last_commit_message() -> str:
|
||||
|
||||
def main():
|
||||
"""Hauptfunktion des Git-Hooks."""
|
||||
# Führe den Hook nur aus, wenn eine aktive Session existiert
|
||||
if not os.path.exists(SESSION_FILE_PATH):
|
||||
sys.exit(0)
|
||||
|
||||
@@ -60,12 +58,29 @@ def main():
|
||||
elapsed_hhmm = decimal_hours_to_hhmm(elapsed_hours)
|
||||
time_comment = f"⏱️ Arbeitszeit in dieser Session: {elapsed_hhmm}\\n"
|
||||
|
||||
# Formatieren der Nachricht für Notion
|
||||
comment = f"✅ New Commit:\\n{time_comment}---\\n{commit_message}"
|
||||
add_comment_to_notion_task(token, task_id, comment)
|
||||
report_content = f"✅ New Commit:\n{time_comment}---\n{commit_message}"
|
||||
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M')
|
||||
|
||||
notion_blocks = [
|
||||
{
|
||||
"object": "block",
|
||||
"type": "heading_2",
|
||||
"heading_2": {
|
||||
"rich_text": [{"type": "text", "text": {"content": f"🤖 Git Commit ({timestamp})"}}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"object": "block",
|
||||
"type": "code",
|
||||
"code": {
|
||||
"rich_text": [{"type": "text", "text": {"content": report_content}}],
|
||||
"language": "yaml"
|
||||
}
|
||||
}
|
||||
]
|
||||
append_blocks_to_notion_page(token, task_id, notion_blocks)
|
||||
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
# Wenn die Datei nicht existiert oder fehlerhaft ist, einfach beenden
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user