2026.06.04 frontend építés közben
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# 🛡️ SENTINEL INFRA - TARGETED BACKUP SYSTEM v2.3
|
||||
|
||||
# --- ⚙️ BEÁLLÍTÁSOK (A te környezeti változóid alapján) ---
|
||||
DB_CONTAINER_NAME="3aa4b73d81e8_shared-postgres"
|
||||
DB_CONTAINER_NAME="shared-postgres"
|
||||
DB_USER="kincses" # <--- Beállítva a te POSTGRES_USER értékedre
|
||||
|
||||
PROJECT_ROOT="/opt/docker/dev/service_finder"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# /opt/docker/dev/service_finder/.roo/scripts/gitea_manager.py
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
import sys
|
||||
@@ -29,34 +28,54 @@ def get_base_url():
|
||||
BASE_URL = get_base_url()
|
||||
|
||||
LABELS = {
|
||||
"Status: To Do": "#ef4444", "Status: In Progress": "#f59e0b", "Status: Done": "#10b981", "Status: Blocked": "#000000",
|
||||
"Scope: Backend": "#0369a1", "Scope: Frontend": "#0284c7", "Scope: API": "#0ea5e9", "Scope: Core": "#38bdf8", "Scope: Robot": "#7dd3fc", "Scope: Database": "#ec4899",
|
||||
"Type: Script": "#8b5cf6", "Type: Model": "#3b82f6", "Type: Database": "#ec4899", "Type: Bug": "#dc2626", "Type: Feature": "#16a34a", "Type: Refactor": "#16a34a",
|
||||
"Role: Admin": "#fb923c", "Role: User": "#fdba74"
|
||||
"Status: To Do": "#ef4444",
|
||||
"Status: In Progress": "#f59e0b",
|
||||
"Status: Done": "#10b981",
|
||||
"Status: Blocked": "#000000",
|
||||
"Scope: Backend": "#0369a1",
|
||||
"Scope: Frontend": "#0284c7",
|
||||
"Scope: API": "#0ea5e9",
|
||||
"Scope: Core": "#38bdf8",
|
||||
"Scope: Robot": "#7dd3fc",
|
||||
"Scope: Database": "#ec4899",
|
||||
"Type: Script": "#8b5cf6",
|
||||
"Type: Model": "#3b82f6",
|
||||
"Type: Bug": "#dc2626",
|
||||
"Type: Feature": "#16a34a",
|
||||
"Type: Refactor": "#16a34a",
|
||||
"Role: Admin": "#fb923c",
|
||||
"Role: User": "#fdba74"
|
||||
}
|
||||
# ================================================
|
||||
|
||||
# ================= SEGÉDFÜGGVÉNYEK =================
|
||||
|
||||
def fetch_all_pages(endpoint):
|
||||
"""Gitea API lapozás (Pagination) kezelése, hogy minden elemet visszakapjunk."""
|
||||
"""Gitea API lapozás (Pagination) kezelése."""
|
||||
all_data = []
|
||||
page = 1
|
||||
limit = 50
|
||||
separator = "&" if "?" in endpoint else "?"
|
||||
|
||||
while True:
|
||||
url = f"{BASE_URL}{endpoint}{separator}limit={limit}&page={page}"
|
||||
res = requests.get(url, headers=HEADERS)
|
||||
if res.status_code != 200:
|
||||
try:
|
||||
res = requests.get(url, headers=HEADERS)
|
||||
if res.status_code != 200:
|
||||
break
|
||||
data = res.json()
|
||||
if not data:
|
||||
break
|
||||
all_data.extend(data)
|
||||
if len(data) < limit:
|
||||
break
|
||||
page += 1
|
||||
except Exception as e:
|
||||
print(f"Hiba a lekérdezés során: {e}")
|
||||
break
|
||||
data = res.json()
|
||||
if not data:
|
||||
break
|
||||
all_data.extend(data)
|
||||
if len(data) < limit:
|
||||
break
|
||||
page += 1
|
||||
return all_data
|
||||
|
||||
def init_labels():
|
||||
"""Címkék inicializálása a tárhelyen."""
|
||||
existing_labels = fetch_all_pages(f"/repos/{OWNER}/{REPO}/labels")
|
||||
existing = {l['name']: l['id'] for l in existing_labels}
|
||||
|
||||
@@ -65,36 +84,19 @@ def init_labels():
|
||||
if name in existing:
|
||||
label_ids[name] = existing[name]
|
||||
else:
|
||||
post_res = requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/labels", headers=HEADERS, json={"name": name, "color": color})
|
||||
if post_res.status_code == 201: label_ids[name] = post_res.json()['id']
|
||||
post_res = requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/labels",
|
||||
headers=HEADERS,
|
||||
json={"name": name, "color": color})
|
||||
if post_res.status_code == 201:
|
||||
label_ids[name] = post_res.json()['id']
|
||||
return label_ids
|
||||
|
||||
def set_issue_state(issue_num, new_state_label, category_labels=[]):
|
||||
label_ids = init_labels()
|
||||
res = requests.get(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/labels", headers=HEADERS)
|
||||
current_ids = [l['id'] for l in res.json()] if res.status_code == 200 else []
|
||||
|
||||
for status in ["Status: To Do", "Status: In Progress", "Status: Done", "Status: Blocked"]:
|
||||
if status in label_ids and label_ids[status] in current_ids:
|
||||
current_ids.remove(label_ids[status])
|
||||
|
||||
if new_state_label in label_ids and label_ids[new_state_label] not in current_ids:
|
||||
current_ids.append(label_ids[new_state_label])
|
||||
|
||||
for cat in category_labels:
|
||||
if cat in label_ids and label_ids[cat] not in current_ids:
|
||||
current_ids.append(label_ids[cat])
|
||||
|
||||
requests.put(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/labels", headers=HEADERS, json={"labels": current_ids})
|
||||
|
||||
def add_comment(issue_num, message):
|
||||
requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/comments", headers=HEADERS, json={"body": message})
|
||||
|
||||
# --- MÉRFÖLDKŐ (MILESTONE) KEZELÉS ---
|
||||
|
||||
def resolve_milestone_id(name_or_id):
|
||||
if not name_or_id: return None
|
||||
if str(name_or_id).isdigit(): return int(name_or_id)
|
||||
"""Mérföldkő ID keresése név vagy ID alapján."""
|
||||
if not name_or_id:
|
||||
return None
|
||||
if str(name_or_id).isdigit():
|
||||
return int(name_or_id)
|
||||
|
||||
milestones = fetch_all_pages(f"/repos/{OWNER}/{REPO}/milestones")
|
||||
for ms in milestones:
|
||||
@@ -102,6 +104,39 @@ def resolve_milestone_id(name_or_id):
|
||||
return ms['id']
|
||||
return None
|
||||
|
||||
def set_issue_state(issue_num, new_state_label, category_labels=None):
|
||||
"""Feladat állapotának (címkéinek) frissítése."""
|
||||
if category_labels is None: category_labels = []
|
||||
label_ids = init_labels()
|
||||
|
||||
# Jelenlegi címkék lekérése
|
||||
res = requests.get(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/labels", headers=HEADERS)
|
||||
current_ids = [l['id'] for l in res.json()] if res.status_code == 200 else []
|
||||
|
||||
# Régi státuszok eltávolítása
|
||||
status_labels = ["Status: To Do", "Status: In Progress", "Status: Done", "Status: Blocked"]
|
||||
for status in status_labels:
|
||||
if status in label_ids and label_ids[status] in current_ids:
|
||||
current_ids.remove(label_ids[status])
|
||||
|
||||
# Új státusz hozzáadása
|
||||
if new_state_label in label_ids:
|
||||
current_ids.append(label_ids[new_state_label])
|
||||
|
||||
# Kategória címkék hozzáadása
|
||||
for cat in category_labels:
|
||||
if cat in label_ids and label_ids[cat] not in current_ids:
|
||||
current_ids.append(label_ids[cat])
|
||||
|
||||
requests.put(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/labels",
|
||||
headers=HEADERS, json={"labels": list(set(current_ids))})
|
||||
|
||||
def add_comment(issue_num, message):
|
||||
requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/comments",
|
||||
headers=HEADERS, json={"body": message})
|
||||
|
||||
# ================= MŰVELETEK =================
|
||||
|
||||
def create_milestone(title, description="", due_date=None):
|
||||
existing_id = resolve_milestone_id(title)
|
||||
if existing_id:
|
||||
@@ -120,76 +155,18 @@ def create_milestone(title, description="", due_date=None):
|
||||
print(f"❌ Hiba a mérföldkő létrehozásakor: {res.text}")
|
||||
return None
|
||||
|
||||
def list_milestones():
|
||||
milestones = fetch_all_pages(f"/repos/{OWNER}/{REPO}/milestones")
|
||||
print(f"\n{'ID':<5} | {'Mérföldkő Címe':<40} | {'Haladás'}")
|
||||
print("-" * 65)
|
||||
for ms in milestones:
|
||||
open_issues = ms.get('open_issues', 0)
|
||||
closed_issues = ms.get('closed_issues', 0)
|
||||
total = open_issues + closed_issues
|
||||
if total > 0:
|
||||
completeness = int((closed_issues / total) * 100)
|
||||
else:
|
||||
completeness = 0
|
||||
print(f"#{ms['id']:<4} | {ms['title'][:40]:<40} | {completeness}%")
|
||||
|
||||
# --- PROJEKT (BOARD) KEZELÉS ---
|
||||
|
||||
def create_repo_project(title, board_type="kanban", description=""):
|
||||
"""Create a new project board in the repository."""
|
||||
payload = {
|
||||
"title": title,
|
||||
"board_type": board_type, # "kanban" or "basic"
|
||||
"description": description
|
||||
}
|
||||
res = requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/projects", headers=HEADERS, json=payload)
|
||||
if res.status_code == 201:
|
||||
project_id = res.json()['id']
|
||||
print(f"✅ Projekt sikeresen létrehozva: '{title}' (ID: {project_id})")
|
||||
return project_id
|
||||
else:
|
||||
print(f"❌ Hiba a projekt létrehozásakor: {res.status_code} - {res.text}")
|
||||
return None
|
||||
|
||||
def list_repo_projects():
|
||||
"""List all projects in the repository."""
|
||||
projects = fetch_all_pages(f"/repos/{OWNER}/{REPO}/projects")
|
||||
print(f"\n{'ID':<5} | {'Projekt Címe':<40} | {'Típus'}")
|
||||
print("-" * 65)
|
||||
for proj in projects:
|
||||
print(f"#{proj['id']:<4} | {proj['title'][:40]:<40} | {proj.get('board_type', 'unknown')}")
|
||||
|
||||
def create_project_board(project_id, title):
|
||||
"""Create a column (board) within a project."""
|
||||
res = requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/projects/{project_id}/columns", headers=HEADERS, json={"title": title})
|
||||
if res.status_code == 201:
|
||||
column_id = res.json()['id']
|
||||
print(f"✅ Projekt oszlop sikeresen létrehozva: '{title}' (ID: {column_id})")
|
||||
return column_id
|
||||
else:
|
||||
print(f"❌ Hiba az oszlop létrehozásakor: {res.status_code} - {res.text}")
|
||||
return None
|
||||
|
||||
# --- KÁRTYA (ISSUE) KEZELÉS ---
|
||||
|
||||
def create_issue(title, body, categories, milestone_ref=None, due_date=None, assignees=None):
|
||||
ms_id = resolve_milestone_id(milestone_ref)
|
||||
|
||||
payload = {"title": title, "body": body}
|
||||
if ms_id:
|
||||
payload["milestone"] = ms_id
|
||||
if due_date:
|
||||
payload["due_date"] = f"{due_date}T23:59:59Z" if len(due_date) == 10 else due_date
|
||||
if assignees:
|
||||
payload["assignees"] = assignees
|
||||
|
||||
if ms_id: payload["milestone"] = ms_id
|
||||
if due_date: payload["due_date"] = f"{due_date}T23:59:59Z" if len(due_date) == 10 else due_date
|
||||
if assignees: payload["assignees"] = assignees if isinstance(assignees, list) else [assignees]
|
||||
|
||||
res = requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues", headers=HEADERS, json=payload)
|
||||
if res.status_code == 201:
|
||||
issue_num = res.json()['number']
|
||||
set_issue_state(issue_num, "Status: To Do", categories)
|
||||
ms_text = f" (Milestone: {ms_id})" if ms_id else ""
|
||||
print(f"✅ Siker: #{issue_num} feladat létrehozva{ms_text}.")
|
||||
print(f"✅ Siker: #{issue_num} feladat létrehozva.")
|
||||
return True
|
||||
print(f"❌ Hiba a kártya létrehozásakor: {res.text}")
|
||||
return False
|
||||
@@ -207,45 +184,12 @@ def finish_issue(issue_num, custom_message=None):
|
||||
requests.post(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}/stopwatch/stop", headers=HEADERS)
|
||||
requests.patch(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}", headers=HEADERS, json={"state": "closed"})
|
||||
|
||||
comment_body = f"✅ **Munka befejezve:** {now}\n\n**Technikai Összefoglaló:**\n{custom_message}\n\n⏱️ *A ráfordított időt a Gitea rögzítette.*" if custom_message else f"✅ **Munka befejezve:** {now}\n⏱️ *A ráfordított időt a Gitea rögzítette.*"
|
||||
add_comment(issue_num, comment_body)
|
||||
print(f"✅ Siker: A #{issue_num} lezárva, időmérés megállítva.")
|
||||
|
||||
def get_issue(issue_num):
|
||||
res = requests.get(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}", headers=HEADERS)
|
||||
if res.status_code != 200:
|
||||
print(f"Hiba: Nem sikerült lekérni a #{issue_num} feladatot. Státusz: {res.status_code}")
|
||||
sys.exit(1)
|
||||
msg = f"✅ **Munka befejezve:** {now}"
|
||||
if custom_message: msg += f"\n\n**Technikai Összefoglaló:**\n{custom_message}"
|
||||
msg += "\n\n⏱️ *Az idő rögzítve.*"
|
||||
|
||||
data = res.json()
|
||||
ms_title = data.get('milestone', {}).get('title', 'Nincs') if data.get('milestone') else 'Nincs'
|
||||
print("=" * 60)
|
||||
print(f"Feladat #{issue_num} - {data.get('state', 'unknown').upper()} (Mérföldkő: {ms_title})")
|
||||
print("=" * 60)
|
||||
print(f"Cím: {data.get('title', 'Nincs cím')}")
|
||||
print("-" * 60)
|
||||
print(data.get('body', 'Nincs leírás'))
|
||||
print("=" * 60)
|
||||
|
||||
def update_issue(issue_num, title=None, body=None):
|
||||
"""Update an issue with new title and/or body."""
|
||||
payload = {}
|
||||
if title is not None:
|
||||
payload["title"] = title
|
||||
if body is not None:
|
||||
payload["body"] = body
|
||||
|
||||
if not payload:
|
||||
print("Nincs módosítandó mező. Használd --title vagy --body paramétert.")
|
||||
return False
|
||||
|
||||
res = requests.patch(f"{BASE_URL}/repos/{OWNER}/{REPO}/issues/{issue_num}", headers=HEADERS, json=payload)
|
||||
if res.status_code in (200, 201):
|
||||
print(f"✅ Siker: A #{issue_num} feladat frissítve.")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Hiba a frissítéskor: {res.status_code} - {res.text}")
|
||||
return False
|
||||
add_comment(issue_num, msg)
|
||||
print(f"✅ Siker: A #{issue_num} lezárva.")
|
||||
|
||||
def list_issues(state="open"):
|
||||
issues = fetch_all_pages(f"/repos/{OWNER}/{REPO}/issues?state={state}")
|
||||
@@ -259,97 +203,35 @@ def list_issues(state="open"):
|
||||
# ================= FŐPROGRAM =================
|
||||
|
||||
if __name__ == "__main__":
|
||||
raw_args = sys.argv[1:]
|
||||
if not raw_args:
|
||||
print("Használat: python3 gitea_manager.py [parancs] [argumentumok]")
|
||||
print(" list - Nyitott kártyák listázása")
|
||||
print(" list closed - Lezárt kártyák listázása")
|
||||
print(" ms list - Mérföldkövek listázása")
|
||||
print(" ms create \"Név\" - Új mérföldkő létrehozása")
|
||||
print(" project list - Projekt táblák listázása")
|
||||
print(" project create \"Cím\" [board_type] [description] - Új projekt létrehozása")
|
||||
print(" board create <project_id> \"Oszlop neve\" - Új oszlop létrehozása projektben")
|
||||
print(" create \"Cím\" \"Leírás\" [Mérföldkő] [Címkék...] [--due YYYY-MM-DD] [--assign username]")
|
||||
print(" start <id> - Munka megkezdése")
|
||||
print(" finish <id> [msg] - Munka lezárása")
|
||||
print(" get <id> - Kártya lekérése")
|
||||
print(" update <id> [--title \"Új cím\"] [--body \"Új leírás\"] - Kártya frissítése")
|
||||
if len(sys.argv) < 2:
|
||||
print("Használat: python3 gitea_manager.py [list|start|finish|create|ms]")
|
||||
sys.exit(1)
|
||||
|
||||
# Paraméterek kinyerése (--due, --assign, --title, --body)
|
||||
args = []
|
||||
due_date = None
|
||||
assignees = []
|
||||
update_title = None
|
||||
update_body = None
|
||||
|
||||
i = 0
|
||||
while i < len(raw_args):
|
||||
if raw_args[i] == "--due" and i + 1 < len(raw_args):
|
||||
due_date = raw_args[i+1]
|
||||
i += 2
|
||||
elif raw_args[i] == "--assign" and i + 1 < len(raw_args):
|
||||
assignees.append(raw_args[i+1])
|
||||
i += 2
|
||||
elif raw_args[i] == "--title" and i + 1 < len(raw_args):
|
||||
update_title = raw_args[i+1]
|
||||
i += 2
|
||||
elif raw_args[i] == "--body" and i + 1 < len(raw_args):
|
||||
update_body = raw_args[i+1]
|
||||
i += 2
|
||||
else:
|
||||
args.append(raw_args[i])
|
||||
i += 1
|
||||
cmd = sys.argv[1].lower()
|
||||
|
||||
action = args[0].lower() if args else ""
|
||||
if cmd == "list":
|
||||
state = sys.argv[2] if len(sys.argv) > 2 else "open"
|
||||
list_issues(state)
|
||||
|
||||
elif cmd == "start" and len(sys.argv) > 2:
|
||||
start_issue(sys.argv[2])
|
||||
|
||||
elif cmd == "finish" and len(sys.argv) > 2:
|
||||
msg = sys.argv[3] if len(sys.argv) > 3 else None
|
||||
finish_issue(sys.argv[2], msg)
|
||||
|
||||
elif cmd == "create" and len(sys.argv) > 3:
|
||||
# Formátum: create "Cím" "Leírás" "Mérföldkő" "Címke1" "Címke2"
|
||||
title = sys.argv[2]
|
||||
body = sys.argv[3]
|
||||
ms = sys.argv[4] if len(sys.argv) > 4 else None
|
||||
cats = sys.argv[5:]
|
||||
create_issue(title, body, cats, ms)
|
||||
|
||||
if action == "list":
|
||||
list_issues(args[1] if len(args) > 1 else "open")
|
||||
|
||||
elif action == "ms":
|
||||
if len(args) > 1 and args[1].lower() == "create":
|
||||
create_milestone(args[2], args[3] if len(args) > 3 else "", due_date)
|
||||
else:
|
||||
list_milestones()
|
||||
|
||||
elif action == "project":
|
||||
if len(args) > 1 and args[1].lower() == "create":
|
||||
title = args[2] if len(args) > 2 else "New Project"
|
||||
board_type = args[3] if len(args) > 3 else "kanban"
|
||||
description = args[4] if len(args) > 4 else ""
|
||||
create_repo_project(title, board_type, description)
|
||||
else:
|
||||
list_repo_projects()
|
||||
|
||||
elif action == "board" and len(args) > 2 and args[1].lower() == "create":
|
||||
project_id = args[2]
|
||||
column_title = args[3] if len(args) > 3 else "New Column"
|
||||
create_project_board(project_id, column_title)
|
||||
|
||||
elif action == "start" and len(args) > 1:
|
||||
start_issue(args[1])
|
||||
|
||||
elif action == "finish" and len(args) > 1:
|
||||
finish_issue(args[1], args[2] if len(args) > 2 else None)
|
||||
|
||||
elif action == "get" and len(args) > 1:
|
||||
get_issue(args[1])
|
||||
|
||||
elif action == "create" and len(args) > 2:
|
||||
title, body = args[1], args[2]
|
||||
milestone_ref = None
|
||||
categories = []
|
||||
|
||||
if len(args) > 3:
|
||||
arg3 = args[3]
|
||||
if any(arg3.startswith(prefix) for prefix in ["Status:", "Scope:", "Type:", "Role:"]):
|
||||
categories = args[3:]
|
||||
else:
|
||||
milestone_ref = arg3
|
||||
categories = args[4:]
|
||||
|
||||
create_issue(title, body, categories, milestone_ref, due_date, assignees)
|
||||
|
||||
elif action == "update" and len(args) > 1:
|
||||
issue_id = args[1]
|
||||
update_issue(issue_id, update_title, update_body)
|
||||
elif cmd == "ms" and len(sys.argv) > 2:
|
||||
if sys.argv[2] == "list":
|
||||
milestones = fetch_all_pages(f"/repos/{OWNER}/{REPO}/milestones")
|
||||
for m in milestones:
|
||||
print(f"ID: {m['id']} | Title: {m['title']}")
|
||||
elif sys.argv[2] == "create" and len(sys.argv) > 3:
|
||||
create_milestone(sys.argv[3])
|
||||
Reference in New Issue
Block a user