diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index fe80db0..641cef6 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -1,4 +1,4 @@ {"id":"gitea-welcome-0kp","title":"Reverse-sync Test","status":"tombstone","priority":2,"issue_type":"task","owner":"chris@rootiest.com","created_at":"2026-01-19T21:09:52.497127424-05:00","created_by":"rootiest","updated_at":"2026-01-19T21:22:16.221889237-05:00","comments":[{"id":2,"issue_id":"gitea-welcome-0kp","author":"rootiest","text":"It","created_at":"2026-01-20T02:11:02Z"}],"deleted_at":"2026-01-19T21:22:16.221889237-05:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"task"} {"id":"gitea-welcome-24k","title":"Reverse-sync Test","status":"tombstone","priority":2,"issue_type":"task","owner":"chris@rootiest.com","created_at":"2026-01-19T21:13:44.940389131-05:00","created_by":"rootiest","updated_at":"2026-01-19T21:22:05.359383908-05:00","deleted_at":"2026-01-19T21:22:05.359383908-05:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"task"} -{"id":"gitea-welcome-5a4","title":"Test Issue","status":"closed","priority":2,"issue_type":"task","owner":"chris@rootiest.com","created_at":"2026-01-19T19:24:28.988421899-05:00","created_by":"rootiest","updated_at":"2026-01-19T20:08:24.331722606-05:00","closed_at":"2026-01-19T20:08:24.331722606-05:00","close_reason":"Closed","comments":[{"id":1,"issue_id":"gitea-welcome-5a4","author":"rootiest","text":"Completed!","created_at":"2026-01-20T01:07:50Z"},{"id":3,"issue_id":"gitea-welcome-5a4","author":"rootiest","text":"New","created_at":"2026-01-20T02:29:01Z"}]} +{"id":"gitea-welcome-5a4","title":"Test Issue","status":"tombstone","priority":2,"issue_type":"task","owner":"chris@rootiest.com","created_at":"2026-01-19T19:24:28.988421899-05:00","created_by":"rootiest","updated_at":"2026-01-19T21:41:09.873551106-05:00","close_reason":"Closed","comments":[{"id":1,"issue_id":"gitea-welcome-5a4","author":"rootiest","text":"Completed!","created_at":"2026-01-20T01:07:50Z"},{"id":3,"issue_id":"gitea-welcome-5a4","author":"rootiest","text":"New","created_at":"2026-01-20T02:29:01Z"}],"deleted_at":"2026-01-19T21:41:09.873551106-05:00","deleted_by":"daemon","delete_reason":"delete","original_type":"task"} {"id":"gitea-welcome-d6r","title":"Reverse-sync Test #2","status":"tombstone","priority":2,"issue_type":"task","owner":"chris@rootiest.com","created_at":"2026-01-19T21:13:44.746027824-05:00","created_by":"rootiest","updated_at":"2026-01-19T21:22:10.935659182-05:00","deleted_at":"2026-01-19T21:22:10.935659182-05:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"task"} diff --git a/.gitea/sync_beads.py b/.gitea/sync_beads.py index fcd49f1..417eaf7 100644 --- a/.gitea/sync_beads.py +++ b/.gitea/sync_beads.py @@ -4,11 +4,12 @@ import requests import sys # Configuration from Environment -TOKEN = os.getenv("GITEA_TOKEN") +TOKEN = os.getenv("MASTER_TOKEN") URL = os.getenv("GITEA_URL") REPO = os.getenv("REPO_NAME") HEADERS = {"Authorization": f"token {TOKEN}", "Content-Type": "application/json"} + def sync(): beads_path = ".beads/issues.jsonl" @@ -57,9 +58,14 @@ def sync(): # --- DELETION / TOMBSTONE LOGIC --- if status == "tombstone": if bid in existing: - issue_num = existing[bid]['number'] - print(f"🗑️ Deleting Gitea Issue #{issue_num} (Tombstone found for {bid})") - del_resp = requests.delete(f"{URL}/api/v1/repos/{REPO}/issues/{issue_num}", headers=HEADERS) + issue_num = existing[bid]["number"] + print( + f"🗑️ Deleting Gitea Issue #{issue_num} (Tombstone found for {bid})" + ) + del_resp = requests.delete( + f"{URL}/api/v1/repos/{REPO}/issues/{issue_num}", + headers=HEADERS, + ) if del_resp.status_code == 204: print(f"✅ Successfully deleted {bid}") deleted_count += 1 @@ -72,8 +78,10 @@ def sync(): # --- STANDARD SYNC LOGIC --- processed_count += 1 - gitea_state = "closed" if status in ["closed", "done", "finished"] else "open" - + gitea_state = ( + "closed" if status in ["closed", "done", "finished"] else "open" + ) + payload = { "title": f"[{bid}] {title}", "body": f"{data.get('description', 'No description provided.')}\n\n---\n**Beads ID:** `{bid}`\n**Type:** `{itype}`", @@ -99,12 +107,15 @@ def sync(): except Exception as e: print(f"⚠️ Error processing bead line: {e}") - print(f"🏁 Finished. Active: {processed_count}, Deleted: {deleted_count}, Skipped: {skipped_count}") + print( + f"🏁 Finished. Active: {processed_count}, Deleted: {deleted_count}, Skipped: {skipped_count}" + ) # Safety check to ensure we didn't process a completely empty file if (processed_count + deleted_count + skipped_count) == 0: print("❌ ERROR: File was found but it was EMPTY.") sys.exit(1) + if __name__ == "__main__": sync()