56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
import clawd_notion as notion
|
|
import sys
|
|
import json
|
|
import os
|
|
import subprocess
|
|
from datetime import datetime
|
|
|
|
SESSION_FILE = ".dev_session/SESSION_INFO"
|
|
|
|
def main():
|
|
if not os.path.exists(SESSION_FILE):
|
|
print("Keine aktive Session.")
|
|
return
|
|
|
|
# Parse args manually strictly for summary
|
|
# Usage: python finish_task.py "My Summary"
|
|
summary = sys.argv[1] if len(sys.argv) > 1 else "Update"
|
|
|
|
with open(SESSION_FILE) as f:
|
|
session = json.load(f)
|
|
|
|
task_id = session["task_id"]
|
|
|
|
# 1. Update Notion
|
|
# Calculate time
|
|
start = datetime.fromisoformat(session["start_time"])
|
|
hours = (datetime.now() - start).total_seconds() / 3600
|
|
|
|
# Get current duration
|
|
# (Skipping read for now, just appending blocks)
|
|
|
|
blocks = [
|
|
{
|
|
"object": "block",
|
|
"type": "heading_2",
|
|
"heading_2": {"rich_text": [{"text": {"content": f"Update {datetime.now().strftime('%Y-%m-%d %H:%M')}"}}]}
|
|
},
|
|
{
|
|
"object": "block",
|
|
"type": "paragraph",
|
|
"paragraph": {"rich_text": [{"text": {"content": f"Time invested: {hours:.2f}h\n\n{summary}"}}]}
|
|
}
|
|
]
|
|
notion.append_blocks(task_id, blocks)
|
|
|
|
# 2. Git Commit
|
|
subprocess.run(["git", "add", "."])
|
|
subprocess.run(["git", "commit", "-m", f"[{task_id[:4]}] {summary}"])
|
|
|
|
# Cleanup
|
|
os.remove(SESSION_FILE)
|
|
print("Session beendet, Notion geupdated, Commited.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|