| 1 | # git.py DOX |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | - Own the `git.py` helper module. |
| 6 | - This module reads local and remote Git release/commit metadata safely. |
| 7 | - Keep this file-level DOX profile synchronized with `git.py` because this directory is intentionally flat. |
| 8 | |
| 9 | ## Ownership |
| 10 | |
| 11 | - `git.py` owns the runtime implementation. |
| 12 | - `git.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation. |
| 13 | - Classes: |
| 14 | - `GitHeadInfo` (no explicit base class) |
| 15 | - `GitReleaseInfo` (no explicit base class) |
| 16 | - `GitRemoteReleaseInfo` (no explicit base class) |
| 17 | - `GitRemoteReleasesResult` (no explicit base class) |
| 18 | - `GitRemoteCommitsInfo` (no explicit base class) |
| 19 | - `GitRepoReleaseInfo` (no explicit base class) |
| 20 | - Top-level functions: |
| 21 | - `strip_auth_from_url(url: str) -> str`: Remove any authentication info from URL. |
| 22 | - `extract_author_repo(url: str) -> tuple[str, str]` |
| 23 | - `_format_git_timestamp(timestamp: int) -> str` |
| 24 | - `_split_describe_version(describe: str) -> tuple[str, int]` |
| 25 | - `_format_release_version(branch: str, short_tag: str, commits_since_tag: int, commit_hash: str) -> str` |
| 26 | - `get_remote_releases(author: str, repo: str) -> GitRemoteReleasesResult` |
| 27 | - `get_remote_commits_since_local(repo_path: str) -> GitRemoteCommitsInfo` |
| 28 | - `get_repo_release_info(repo_path: str) -> GitRepoReleaseInfo` |
| 29 | - `get_git_info()` |
| 30 | - `get_version()` |
| 31 | - `is_official_agent_zero_repo() -> bool`: Return True when origin points to agent0ai/agent-zero. |
| 32 | - `clone_repo(url: str, dest: str, token: str | None=...)`: Clone a git repository. Uses http.extraHeader for token auth (never stored in URL/config). |
| 33 | - `DirtyTreeConflictError`: Reports a plugin update that was rolled back because its local edits conflict with upstream. |
| 34 | - `update_repo(repo_path: str, auto_stash: bool = True) -> Repo`: Temporarily stashes tracked plugin edits for an update, then restores them; on conflict it restores the original checkout and edits before raising `DirtyTreeConflictError`. |
| 35 | - `get_repo_status(repo_path: str) -> dict`: Get Git repository status, ignoring A0 project metadata files. |
| 36 | - Notable constants/configuration names: `A0_IGNORE_PATTERNS`. |
| 37 | |
| 38 | ## Runtime Contracts |
| 39 | |
| 40 | - Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together. |
| 41 | - Git commit and release timestamp strings produced by `_format_git_timestamp` use UTC and omit a timezone suffix. |
| 42 | - Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change. |
| 43 | - Observed side-effect areas: filesystem writes, filesystem deletion, network calls, subprocess/runtime control, plugin state, settings/state persistence, secret handling. |
| 44 | - Imported dependency areas include: `base64`, `dataclasses`, `datetime`, `git`, `giturlparse`, `helpers`, `helpers.localization`, `os`, `re`, `subprocess`, `urllib.parse`. |
| 45 | |
| 46 | ## Key Concepts |
| 47 | |
| 48 | - Important called helpers/classes observed in the source: `urlparse`, `urlunparse`, `parse`, `strip`, `repo.endswith`, `datetime.fromtimestamp.strftime`, `describe.strip`, `re.fullmatch`, `files.get_base_dir`, `get_repo_release_info`, `os.environ.copy`, `subprocess.run`, `Repo`, `repo.active_branch.tracking_branch`, `strip_auth_from_url`, `ValueError`, `match.group`, `branch.upper`, `author.strip`, `repo.strip`. |
| 49 | - Keep request/response, tool, or helper semantics documented here at the same time as source changes. |
| 50 | |
| 51 | ## Work Guidance |
| 52 | |
| 53 | - Preserve public helper APIs used by core code and plugins unless every caller is updated. |
| 54 | - Keep path, auth, secret, persistence, network, and subprocess behavior explicit and bounded. |
| 55 | - Prefer adding cohesive helper functions here only when behavior is reused across modules. |
| 56 | |
| 57 | ## Verification |
| 58 | |
| 59 | - Run targeted tests for changed helper behavior; run security regressions for auth, filesystem, WebSocket, tunnel, upload, or secret-handling helpers. |
| 60 | - Related tests observed by source search: |
| 61 | - `tests/test_docker_release_plan.py` |
| 62 | - `tests/test_git_version_label.py` |
| 63 | - `tests/test_model_config_api_keys.py` |
| 64 | - `tests/test_model_config_project_presets.py` |
| 65 | - `tests/test_model_search.py` |
| 66 | - `tests/test_oauth_github_copilot.py` |
| 67 | - `tests/test_oauth_providers.py` |
| 68 | - `tests/test_onboarding_static.py` |
| 69 | |
| 70 | ## Child DOX Index |
| 71 | |
| 72 | No child DOX files. |