diff --git a/.gitignore b/.gitignore index b27c445..f66dbd2 100644 --- a/.gitignore +++ b/.gitignore @@ -69,5 +69,20 @@ PROJECT_SUMMARY.md QUICKSTART.md VS_CODE_SETUP.md +# Gemini / Antigravity +.gemini/ + # Windows artifacts nul + +# Debug / temp files (generated during development & testing) +out.txt +containers.txt +helper.txt +logs.txt +port.txt +env.txt +network.txt +update_helper.txt +state.txt +hostpath.txt diff --git a/app/routers/settings.py b/app/routers/settings.py index 26e15e2..93343f7 100644 --- a/app/routers/settings.py +++ b/app/routers/settings.py @@ -334,6 +334,19 @@ async def get_version( return result +@router.get("/branches") +async def get_branches( + current_user: User = Depends(get_current_user), + db: Session = Depends(get_db), +): + """Return a list of available branches from the configured git remote.""" + config = get_system_config(db) + if not config or not config.git_repo_url: + return [] + branches = await update_service.get_remote_branches(config) + return branches + + @router.post("/update") async def trigger_update( current_user: User = Depends(get_current_user), diff --git a/app/services/update_service.py b/app/services/update_service.py index 65f38ea..3307e7e 100644 --- a/app/services/update_service.py +++ b/app/services/update_service.py @@ -5,6 +5,7 @@ import logging import os import shutil import subprocess +import httpx from datetime import datetime from pathlib import Path from typing import Any @@ -130,6 +131,42 @@ async def check_for_updates(config: Any) -> dict: } +async def get_remote_branches(config: Any) -> list[str]: + """Query the Gitea API for available branches on the configured repository. + + Returns a list of branch names (e.g., ['main', 'unstable', 'development']). + If the repository URL is not configured or an error occurs, returns an empty list. + """ + if not config.git_repo_url: + return [] + + repo_url = config.git_repo_url.rstrip("/") + parts = repo_url.split("/") + if len(parts) < 5: + return [] + + base_url = "/".join(parts[:-2]) + owner = parts[-2] + repo = parts[-1] + branches_api = f"{base_url}/api/v1/repos/{owner}/{repo}/branches?limit=100" + + headers = {} + if config.git_token: + headers["Authorization"] = f"token {config.git_token}" + + try: + async with httpx.AsyncClient(timeout=10) as client: + resp = await client.get(branches_api, headers=headers) + if resp.status_code == 200: + data = resp.json() + if isinstance(data, list): + return [branch.get("name") for branch in data if "name" in branch] + except Exception as exc: + logger.error("Error fetching branches: %s", exc) + + return [] + + def backup_database(db_path: str) -> str: """Create a timestamped backup of the SQLite database. diff --git a/containers.txt b/containers.txt deleted file mode 100644 index d1222b7..0000000 --- a/containers.txt +++ /dev/null @@ -1,9 +0,0 @@ -NAMES STATUS IMAGE -netbird-msp-appliance Up 3 minutes (healthy) netbirdmsp-appliance-netbird-msp-appliance -msp-updater Exited (0) 3 minutes ago netbirdmsp-appliance-netbird-msp-appliance:latest -netbird-kunde1-caddy Up 2 hours caddy:2-alpine -netbird-kunde1-signal Up 2 hours netbirdio/signal:latest -netbird-kunde1-dashboard Up 2 hours netbirdio/dashboard:latest -netbird-kunde1-relay Up 2 hours netbirdio/relay:latest -netbird-kunde1-management Up 2 hours netbirdio/management:latest -docker-socket-proxy Up 2 hours tecnativa/docker-socket-proxy:latest diff --git a/env.txt b/env.txt deleted file mode 100644 index e69de29..0000000 diff --git a/helper.txt b/helper.txt deleted file mode 100644 index a7601a8..0000000 --- a/helper.txt +++ /dev/null @@ -1 +0,0 @@ -Error response from daemon: No such container: msp-updater diff --git a/logs.txt b/logs.txt deleted file mode 100644 index ce1de1b..0000000 --- a/logs.txt +++ /dev/null @@ -1,9 +0,0 @@ -INFO: Started server process [1] -INFO: Waiting for application startup. -2026-02-22 14:53:59,694 [INFO] app.main: Starting NetBird MSP Appliance... -2026-02-22 14:53:59,744 [INFO] app.main: Database initialized. -INFO: Application startup complete. -INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) -INFO: 127.0.0.1:45370 - "GET /api/health HTTP/1.1" 200 OK -INFO: 127.0.0.1:57724 - "GET /api/health HTTP/1.1" 200 OK -INFO: 127.0.0.1:56212 - "GET /api/health HTTP/1.1" 200 OK diff --git a/network.txt b/network.txt deleted file mode 100644 index e69de29..0000000 diff --git a/out.txt b/out.txt deleted file mode 100644 index 71b00a0..0000000 --- a/out.txt +++ /dev/null @@ -1 +0,0 @@ -msp-updater diff --git a/port.txt b/port.txt deleted file mode 100644 index ddb881a..0000000 --- a/port.txt +++ /dev/null @@ -1,2 +0,0 @@ -8000/tcp -> 0.0.0.0:8000 -8000/tcp -> [::]:8000 diff --git a/static/index.html b/static/index.html index 8fdd1d7..d43fa95 100644 --- a/static/index.html +++ b/static/index.html @@ -363,48 +363,54 @@