fix: commit semantic repair changes

This commit is contained in:
2026-03-21 11:22:25 +03:00
parent d47826b50b
commit 978fe7b34d
272 changed files with 4603 additions and 1668 deletions

View File

@@ -1,4 +1,4 @@
# [DEF:backend.src.services.git_service:Module]
# [DEF:git_service:Module]
#
# @COMPLEXITY: 3
# @SEMANTICS: git, service, gitpython, repository, version_control
@@ -31,7 +31,7 @@ from src.models.git import GitRepository, GitServerConfig
from src.models.config import AppConfigRecord
from src.core.database import SessionLocal
# [DEF:backend.src.services.git_service.GitService:Class]
# [DEF:GitService:Class]
# @COMPLEXITY: 3
# @PURPOSE: Wrapper for GitPython operations with semantic logging and error handling.
class GitService:
@@ -39,7 +39,7 @@ class GitService:
Wrapper for GitPython operations.
"""
# [DEF:backend.src.services.git_service.GitService.__init__:Function]
# [DEF:GitService_init:Function]
# @PURPOSE: Initializes the GitService with a base path for repositories.
# @PARAM: base_path (str) - Root directory for all Git clones.
# @PRE: base_path is a valid string path.
@@ -53,9 +53,9 @@ class GitService:
self._uses_default_base_path = base_path == "git_repos"
self.base_path = self._resolve_base_path(base_path)
self._ensure_base_path_exists()
# [/DEF:backend.src.services.git_service.GitService.__init__:Function]
# [/DEF:GitService_init:Function]
# [DEF:backend.src.services.git_service.GitService._ensure_base_path_exists:Function]
# [DEF:_ensure_base_path_exists:Function]
# @PURPOSE: Ensure the repositories root directory exists and is a directory.
# @PRE: self.base_path is resolved to filesystem path.
# @POST: self.base_path exists as directory or raises ValueError.
@@ -72,9 +72,9 @@ class GitService:
f"[_ensure_base_path_exists][Coherence:Failed] Cannot create Git repositories base path: {self.base_path}. Error: {e}"
)
raise ValueError(f"Cannot create Git repositories base path: {self.base_path}. {e}")
# [/DEF:backend.src.services.git_service.GitService._ensure_base_path_exists:Function]
# [/DEF:_ensure_base_path_exists:Function]
# [DEF:backend.src.services.git_service.GitService._resolve_base_path:Function]
# [DEF:_resolve_base_path:Function]
# @PURPOSE: Resolve base repository directory from explicit argument or global storage settings.
# @PRE: base_path is a string path.
# @POST: Returns absolute path for Git repositories root.
@@ -115,9 +115,9 @@ class GitService:
except Exception as e:
logger.warning(f"[_resolve_base_path][Coherence:Failed] Falling back to default path: {e}")
return fallback_path
# [/DEF:backend.src.services.git_service.GitService._resolve_base_path:Function]
# [/DEF:_resolve_base_path:Function]
# [DEF:backend.src.services.git_service.GitService._normalize_repo_key:Function]
# [DEF:_normalize_repo_key:Function]
# @PURPOSE: Convert user/dashboard-provided key to safe filesystem directory name.
# @PRE: repo_key can be None/empty.
# @POST: Returns normalized non-empty key.
@@ -127,9 +127,9 @@ class GitService:
raw_key = str(repo_key or "").strip().lower()
normalized = re.sub(r"[^a-z0-9._-]+", "-", raw_key).strip("._-")
return normalized or "dashboard"
# [/DEF:backend.src.services.git_service.GitService._normalize_repo_key:Function]
# [/DEF:_normalize_repo_key:Function]
# [DEF:backend.src.services.git_service.GitService._update_repo_local_path:Function]
# [DEF:_update_repo_local_path:Function]
# @PURPOSE: Persist repository local_path in GitRepository table when record exists.
# @PRE: dashboard_id is valid integer.
# @POST: local_path is updated for existing record.
@@ -151,9 +151,9 @@ class GitService:
session.close()
except Exception as e:
logger.warning(f"[_update_repo_local_path][Coherence:Failed] {e}")
# [/DEF:backend.src.services.git_service.GitService._update_repo_local_path:Function]
# [/DEF:_update_repo_local_path:Function]
# [DEF:backend.src.services.git_service.GitService._migrate_repo_directory:Function]
# [DEF:_migrate_repo_directory:Function]
# @PURPOSE: Move legacy repository directory to target path and sync DB metadata.
# @PRE: source_path exists.
# @POST: Repository content available at target_path.
@@ -182,9 +182,9 @@ class GitService:
f"[_migrate_repo_directory][Coherence:OK] Repository migrated for dashboard {dashboard_id}: {source_abs} -> {target_abs}"
)
return target_abs
# [/DEF:backend.src.services.git_service.GitService._migrate_repo_directory:Function]
# [/DEF:_migrate_repo_directory:Function]
# [DEF:backend.src.services.git_service.GitService._ensure_gitflow_branches:Function]
# [DEF:_ensure_gitflow_branches:Function]
# @PURPOSE: Ensure standard GitFlow branches (main/dev/preprod) exist locally and on origin.
# @PRE: repo is a valid GitPython Repo instance.
# @POST: main, dev, preprod are available in local repository and pushed to origin when available.
@@ -267,9 +267,9 @@ class GitService:
logger.warning(
f"[_ensure_gitflow_branches][Action] Could not checkout dev branch for dashboard {dashboard_id}: {e}"
)
# [/DEF:backend.src.services.git_service.GitService._ensure_gitflow_branches:Function]
# [/DEF:_ensure_gitflow_branches:Function]
# [DEF:backend.src.services.git_service.GitService._get_repo_path:Function]
# [DEF:_get_repo_path:Function]
# @PURPOSE: Resolves the local filesystem path for a dashboard's repository.
# @PARAM: dashboard_id (int)
# @PARAM: repo_key (Optional[str]) - Slug-like key used when DB local_path is absent.
@@ -321,9 +321,9 @@ class GitService:
self._update_repo_local_path(dashboard_id, target_path)
return target_path
# [/DEF:backend.src.services.git_service.GitService._get_repo_path:Function]
# [/DEF:_get_repo_path:Function]
# [DEF:backend.src.services.git_service.GitService.init_repo:Function]
# [DEF:init_repo:Function]
# @PURPOSE: Initialize or clone a repository for a dashboard.
# @PARAM: dashboard_id (int)
# @PARAM: remote_url (str)
@@ -371,9 +371,9 @@ class GitService:
repo = Repo.clone_from(auth_url, repo_path)
self._ensure_gitflow_branches(repo, dashboard_id)
return repo
# [/DEF:backend.src.services.git_service.GitService.init_repo:Function]
# [/DEF:init_repo:Function]
# [DEF:backend.src.services.git_service.GitService.delete_repo:Function]
# [DEF:delete_repo:Function]
# @PURPOSE: Remove local repository and DB binding for a dashboard.
# @PRE: dashboard_id is a valid integer.
# @POST: Local path is deleted when present and GitRepository row is removed.
@@ -420,9 +420,9 @@ class GitService:
raise HTTPException(status_code=500, detail=f"Failed to delete repository: {str(e)}")
finally:
session.close()
# [/DEF:backend.src.services.git_service.GitService.delete_repo:Function]
# [/DEF:delete_repo:Function]
# [DEF:backend.src.services.git_service.GitService.get_repo:Function]
# [DEF:get_repo:Function]
# @PURPOSE: Get Repo object for a dashboard.
# @PRE: Repository must exist on disk for the given dashboard_id.
# @POST: Returns a GitPython Repo instance for the dashboard.
@@ -439,9 +439,9 @@ class GitService:
except Exception as e:
logger.error(f"[get_repo][Coherence:Failed] Failed to open repository at {repo_path}: {e}")
raise HTTPException(status_code=500, detail="Failed to open local Git repository")
# [/DEF:backend.src.services.git_service.GitService.get_repo:Function]
# [/DEF:get_repo:Function]
# [DEF:backend.src.services.git_service.GitService.configure_identity:Function]
# [DEF:configure_identity:Function]
# @PURPOSE: Configure repository-local Git committer identity for user-scoped operations.
# @PRE: dashboard_id repository exists; git_username/git_email may be empty.
# @POST: Repository config has user.name and user.email when both identity values are provided.
@@ -471,9 +471,9 @@ class GitService:
except Exception as e:
logger.error(f"[configure_identity][Coherence:Failed] Failed to configure git identity: {e}")
raise HTTPException(status_code=500, detail=f"Failed to configure git identity: {str(e)}")
# [/DEF:backend.src.services.git_service.GitService.configure_identity:Function]
# [/DEF:configure_identity:Function]
# [DEF:backend.src.services.git_service.GitService.list_branches:Function]
# [DEF:list_branches:Function]
# @PURPOSE: List all branches for a dashboard's repository.
# @PRE: Repository for dashboard_id exists.
# @POST: Returns a list of branch metadata dictionaries.
@@ -526,9 +526,9 @@ class GitService:
})
return branches
# [/DEF:backend.src.services.git_service.GitService.list_branches:Function]
# [/DEF:list_branches:Function]
# [DEF:backend.src.services.git_service.GitService.create_branch:Function]
# [DEF:create_branch:Function]
# @PURPOSE: Create a new branch from an existing one.
# @PARAM: name (str) - New branch name.
# @PARAM: from_branch (str) - Source branch.
@@ -563,9 +563,9 @@ class GitService:
except Exception as e:
logger.error(f"[create_branch][Coherence:Failed] {e}")
raise
# [/DEF:backend.src.services.git_service.GitService.create_branch:Function]
# [/DEF:create_branch:Function]
# [DEF:backend.src.services.git_service.GitService.checkout_branch:Function]
# [DEF:checkout_branch:Function]
# @PURPOSE: Switch to a specific branch.
# @PRE: Repository exists and the specified branch name exists.
# @POST: The repository working directory is updated to the specified branch.
@@ -575,9 +575,9 @@ class GitService:
repo = self.get_repo(dashboard_id)
logger.info(f"[checkout_branch][Action] Checking out branch {name}")
repo.git.checkout(name)
# [/DEF:backend.src.services.git_service.GitService.checkout_branch:Function]
# [/DEF:checkout_branch:Function]
# [DEF:backend.src.services.git_service.GitService.commit_changes:Function]
# [DEF:commit_changes:Function]
# @PURPOSE: Stage and commit changes.
# @PARAM: message (str) - Commit message.
# @PARAM: files (List[str]) - Optional list of specific files to stage.
@@ -602,9 +602,9 @@ class GitService:
repo.index.commit(message)
logger.info(f"[commit_changes][Coherence:OK] Committed changes with message: {message}")
# [/DEF:backend.src.services.git_service.GitService.commit_changes:Function]
# [/DEF:commit_changes:Function]
# [DEF:backend.src.services.git_service.GitService._extract_http_host:Function]
# [DEF:_extract_http_host:Function]
# @PURPOSE: Extract normalized host[:port] from HTTP(S) URL.
# @PRE: url_value may be empty.
# @POST: Returns lowercase host token or None.
@@ -626,9 +626,9 @@ class GitService:
if parsed.port:
return f"{host.lower()}:{parsed.port}"
return host.lower()
# [/DEF:backend.src.services.git_service.GitService._extract_http_host:Function]
# [/DEF:_extract_http_host:Function]
# [DEF:backend.src.services.git_service.GitService._strip_url_credentials:Function]
# [DEF:_strip_url_credentials:Function]
# @PURPOSE: Remove credentials from URL while preserving scheme/host/path.
# @PRE: url_value may contain credentials.
# @POST: Returns URL without username/password.
@@ -648,9 +648,9 @@ class GitService:
if parsed.port:
host = f"{host}:{parsed.port}"
return parsed._replace(netloc=host).geturl()
# [/DEF:backend.src.services.git_service.GitService._strip_url_credentials:Function]
# [/DEF:_strip_url_credentials:Function]
# [DEF:backend.src.services.git_service.GitService._replace_host_in_url:Function]
# [DEF:_replace_host_in_url:Function]
# @PURPOSE: Replace source URL host with host from configured server URL.
# @PRE: source_url and config_url are HTTP(S) URLs.
# @POST: Returns source URL with updated host (credentials preserved) or None.
@@ -687,9 +687,9 @@ class GitService:
new_netloc = f"{auth_part}{target_host}"
return source_parsed._replace(netloc=new_netloc).geturl()
# [/DEF:backend.src.services.git_service.GitService._replace_host_in_url:Function]
# [/DEF:_replace_host_in_url:Function]
# [DEF:backend.src.services.git_service.GitService._align_origin_host_with_config:Function]
# [DEF:_align_origin_host_with_config:Function]
# @PURPOSE: Auto-align local origin host to configured Git server host when they drift.
# @PRE: origin remote exists.
# @POST: origin URL host updated and DB binding normalized when mismatch detected.
@@ -756,9 +756,9 @@ class GitService:
)
return aligned_url
# [/DEF:backend.src.services.git_service.GitService._align_origin_host_with_config:Function]
# [/DEF:_align_origin_host_with_config:Function]
# [DEF:backend.src.services.git_service.GitService.push_changes:Function]
# [DEF:push_changes:Function]
# @PURPOSE: Push local commits to remote.
# @PRE: Repository exists and has an 'origin' remote.
# @POST: Local branch commits are pushed to origin.
@@ -871,9 +871,9 @@ class GitService:
except Exception as e:
logger.error(f"[push_changes][Coherence:Failed] Failed to push changes: {e}")
raise HTTPException(status_code=500, detail=f"Git push failed: {str(e)}")
# [/DEF:backend.src.services.git_service.GitService.push_changes:Function]
# [/DEF:push_changes:Function]
# [DEF:backend.src.services.git_service.GitService._read_blob_text:Function]
# [DEF:_read_blob_text:Function]
# @PURPOSE: Read text from a Git blob.
# @RELATION: USES -> [Blob]
def _read_blob_text(self, blob: Blob) -> str:
@@ -884,9 +884,9 @@ class GitService:
return blob.data_stream.read().decode("utf-8", errors="replace")
except Exception:
return ""
# [/DEF:backend.src.services.git_service.GitService._read_blob_text:Function]
# [/DEF:_read_blob_text:Function]
# [DEF:backend.src.services.git_service.GitService._get_unmerged_file_paths:Function]
# [DEF:_get_unmerged_file_paths:Function]
# @PURPOSE: List files with merge conflicts.
# @RELATION: USES -> [Repo]
def _get_unmerged_file_paths(self, repo: Repo) -> List[str]:
@@ -895,9 +895,9 @@ class GitService:
return sorted(list(repo.index.unmerged_blobs().keys()))
except Exception:
return []
# [/DEF:backend.src.services.git_service.GitService._get_unmerged_file_paths:Function]
# [/DEF:_get_unmerged_file_paths:Function]
# [DEF:backend.src.services.git_service.GitService._build_unfinished_merge_payload:Function]
# [DEF:_build_unfinished_merge_payload:Function]
# @PURPOSE: Build payload for unfinished merge state.
# @RELATION: CALLS -> [GitService._get_unmerged_file_paths]
def _build_unfinished_merge_payload(self, repo: Repo) -> Dict[str, Any]:
@@ -949,9 +949,9 @@ class GitService:
"git merge --abort",
],
}
# [/DEF:backend.src.services.git_service.GitService._build_unfinished_merge_payload:Function]
# [/DEF:_build_unfinished_merge_payload:Function]
# [DEF:backend.src.services.git_service.GitService.get_merge_status:Function]
# [DEF:get_merge_status:Function]
# @PURPOSE: Get current merge status for a dashboard repository.
# @RELATION: CALLS -> [GitService.get_repo]
# @RELATION: CALLS -> [GitService._build_unfinished_merge_payload]
@@ -984,9 +984,9 @@ class GitService:
"merge_message_preview": payload["merge_message_preview"],
"conflicts_count": int(payload.get("conflicts_count") or 0),
}
# [/DEF:backend.src.services.git_service.GitService.get_merge_status:Function]
# [/DEF:get_merge_status:Function]
# [DEF:backend.src.services.git_service.GitService.get_merge_conflicts:Function]
# [DEF:get_merge_conflicts:Function]
# @PURPOSE: List all files with conflicts and their contents.
# @RELATION: CALLS -> [GitService.get_repo]
# @RELATION: CALLS -> [GitService._read_blob_text]
@@ -1011,9 +1011,9 @@ class GitService:
}
)
return sorted(conflicts, key=lambda item: item["file_path"])
# [/DEF:backend.src.services.git_service.GitService.get_merge_conflicts:Function]
# [/DEF:get_merge_conflicts:Function]
# [DEF:backend.src.services.git_service.GitService.resolve_merge_conflicts:Function]
# [DEF:resolve_merge_conflicts:Function]
# @PURPOSE: Resolve conflicts using specified strategy.
# @RELATION: CALLS -> [GitService.get_repo]
def resolve_merge_conflicts(self, dashboard_id: int, resolutions: List[Dict[str, Any]]) -> List[str]:
@@ -1049,9 +1049,9 @@ class GitService:
resolved_files.append(file_path)
return resolved_files
# [/DEF:backend.src.services.git_service.GitService.resolve_merge_conflicts:Function]
# [/DEF:resolve_merge_conflicts:Function]
# [DEF:backend.src.services.git_service.GitService.abort_merge:Function]
# [DEF:abort_merge:Function]
# @PURPOSE: Abort ongoing merge.
# @RELATION: CALLS -> [GitService.get_repo]
def abort_merge(self, dashboard_id: int) -> Dict[str, Any]:
@@ -1066,9 +1066,9 @@ class GitService:
return {"status": "no_merge_in_progress"}
raise HTTPException(status_code=409, detail=f"Cannot abort merge: {details}")
return {"status": "aborted"}
# [/DEF:backend.src.services.git_service.GitService.abort_merge:Function]
# [/DEF:abort_merge:Function]
# [DEF:backend.src.services.git_service.GitService.continue_merge:Function]
# [DEF:continue_merge:Function]
# @PURPOSE: Finalize merge after conflict resolution.
# @RELATION: CALLS -> [GitService.get_repo]
# @RELATION: CALLS -> [GitService._get_unmerged_file_paths]
@@ -1104,9 +1104,9 @@ class GitService:
except Exception:
commit_hash = ""
return {"status": "committed", "commit_hash": commit_hash}
# [/DEF:backend.src.services.git_service.GitService.continue_merge:Function]
# [/DEF:continue_merge:Function]
# [DEF:backend.src.services.git_service.GitService.pull_changes:Function]
# [DEF:pull_changes:Function]
# @PURPOSE: Pull changes from remote.
# @PRE: Repository exists and has an 'origin' remote.
# @POST: Changes from origin are pulled and merged into the active branch.
@@ -1189,9 +1189,9 @@ class GitService:
except Exception as e:
logger.error(f"[pull_changes][Coherence:Failed] Failed to pull changes: {e}")
raise HTTPException(status_code=500, detail=f"Git pull failed: {str(e)}")
# [/DEF:backend.src.services.git_service.GitService.pull_changes:Function]
# [/DEF:pull_changes:Function]
# [DEF:backend.src.services.git_service.GitService.get_status:Function]
# [DEF:get_status:Function]
# @PURPOSE: Get current repository status (dirty files, untracked, etc.)
# @PRE: Repository for dashboard_id exists.
# @POST: Returns a dictionary representing the Git status.
@@ -1266,9 +1266,9 @@ class GitService:
"is_diverged": is_diverged,
"sync_state": sync_state,
}
# [/DEF:backend.src.services.git_service.GitService.get_status:Function]
# [/DEF:get_status:Function]
# [DEF:backend.src.services.git_service.GitService.get_diff:Function]
# [DEF:get_diff:Function]
# @PURPOSE: Generate diff for a file or the whole repository.
# @PARAM: file_path (str) - Optional specific file.
# @PARAM: staged (bool) - Whether to show staged changes.
@@ -1286,9 +1286,9 @@ class GitService:
if file_path:
return repo.git.diff(*diff_args, "--", file_path)
return repo.git.diff(*diff_args)
# [/DEF:backend.src.services.git_service.GitService.get_diff:Function]
# [/DEF:get_diff:Function]
# [DEF:backend.src.services.git_service.GitService.get_commit_history:Function]
# [DEF:get_commit_history:Function]
# @PURPOSE: Retrieve commit history for a repository.
# @PARAM: limit (int) - Max number of commits to return.
# @PRE: Repository for dashboard_id exists.
@@ -1317,9 +1317,9 @@ class GitService:
logger.warning(f"[get_commit_history][Action] Could not retrieve commit history for dashboard {dashboard_id}: {e}")
return []
return commits
# [/DEF:backend.src.services.git_service.GitService.get_commit_history:Function]
# [/DEF:get_commit_history:Function]
# [DEF:backend.src.services.git_service.GitService.test_connection:Function]
# [DEF:test_connection:Function]
# @PURPOSE: Test connection to Git provider using PAT.
# @PARAM: provider (GitProvider)
# @PARAM: url (str)
@@ -1368,9 +1368,9 @@ class GitService:
except Exception as e:
logger.error(f"[test_connection][Coherence:Failed] Error testing git connection: {e}")
return False
# [/DEF:backend.src.services.git_service.GitService.test_connection:Function]
# [/DEF:test_connection:Function]
# [DEF:backend.src.services.git_service.GitService._normalize_git_server_url:Function]
# [DEF:_normalize_git_server_url:Function]
# @PURPOSE: Normalize Git server URL for provider API calls.
# @PRE: raw_url is non-empty.
# @POST: Returns URL without trailing slash.
@@ -1380,9 +1380,9 @@ class GitService:
if not normalized:
raise HTTPException(status_code=400, detail="Git server URL is required")
return normalized.rstrip("/")
# [/DEF:backend.src.services.git_service.GitService._normalize_git_server_url:Function]
# [/DEF:_normalize_git_server_url:Function]
# [DEF:backend.src.services.git_service.GitService._gitea_headers:Function]
# [DEF:_gitea_headers:Function]
# @PURPOSE: Build Gitea API authorization headers.
# @PRE: pat is provided.
# @POST: Returns headers with token auth.
@@ -1396,9 +1396,9 @@ class GitService:
"Content-Type": "application/json",
"Accept": "application/json",
}
# [/DEF:backend.src.services.git_service.GitService._gitea_headers:Function]
# [/DEF:_gitea_headers:Function]
# [DEF:backend.src.services.git_service.GitService._gitea_request:Function]
# [DEF:_gitea_request:Function]
# @PURPOSE: Execute HTTP request against Gitea API with stable error mapping.
# @PRE: method and endpoint are valid.
# @POST: Returns decoded JSON payload.
@@ -1446,9 +1446,9 @@ class GitService:
if response.status_code == 204:
return None
return response.json()
# [/DEF:backend.src.services.git_service.GitService._gitea_request:Function]
# [/DEF:_gitea_request:Function]
# [DEF:backend.src.services.git_service.GitService.get_gitea_current_user:Function]
# [DEF:get_gitea_current_user:Function]
# @PURPOSE: Resolve current Gitea user for PAT.
# @PRE: server_url and pat are valid.
# @POST: Returns current username.
@@ -1460,9 +1460,9 @@ class GitService:
if not username:
raise HTTPException(status_code=500, detail="Failed to resolve Gitea username")
return str(username)
# [/DEF:backend.src.services.git_service.GitService.get_gitea_current_user:Function]
# [/DEF:get_gitea_current_user:Function]
# [DEF:backend.src.services.git_service.GitService.list_gitea_repositories:Function]
# [DEF:list_gitea_repositories:Function]
# @PURPOSE: List repositories visible to authenticated Gitea user.
# @PRE: server_url and pat are valid.
# @POST: Returns repository list from Gitea.
@@ -1478,9 +1478,9 @@ class GitService:
if not isinstance(payload, list):
return []
return payload
# [/DEF:backend.src.services.git_service.GitService.list_gitea_repositories:Function]
# [/DEF:list_gitea_repositories:Function]
# [DEF:backend.src.services.git_service.GitService.create_gitea_repository:Function]
# [DEF:create_gitea_repository:Function]
# @PURPOSE: Create repository in Gitea for authenticated user.
# @PRE: name is non-empty and PAT has repo creation permission.
# @POST: Returns created repository payload.
@@ -1515,9 +1515,9 @@ class GitService:
if not isinstance(created, dict):
raise HTTPException(status_code=500, detail="Unexpected Gitea response while creating repository")
return created
# [/DEF:backend.src.services.git_service.GitService.create_gitea_repository:Function]
# [/DEF:create_gitea_repository:Function]
# [DEF:backend.src.services.git_service.GitService.delete_gitea_repository:Function]
# [DEF:delete_gitea_repository:Function]
# @PURPOSE: Delete repository in Gitea.
# @PRE: owner and repo_name are non-empty.
# @POST: Repository deleted on Gitea server.
@@ -1537,9 +1537,9 @@ class GitService:
pat,
f"/repos/{owner}/{repo_name}",
)
# [/DEF:backend.src.services.git_service.GitService.delete_gitea_repository:Function]
# [/DEF:delete_gitea_repository:Function]
# [DEF:backend.src.services.git_service.GitService._gitea_branch_exists:Function]
# [DEF:_gitea_branch_exists:Function]
# @PURPOSE: Check whether a branch exists in Gitea repository.
# @PRE: owner/repo/branch are non-empty.
# @POST: Returns True when branch exists, False when 404.
@@ -1563,9 +1563,9 @@ class GitService:
if exc.status_code == 404:
return False
raise
# [/DEF:backend.src.services.git_service.GitService._gitea_branch_exists:Function]
# [/DEF:_gitea_branch_exists:Function]
# [DEF:backend.src.services.git_service.GitService._build_gitea_pr_404_detail:Function]
# [DEF:_build_gitea_pr_404_detail:Function]
# @PURPOSE: Build actionable error detail for Gitea PR 404 responses.
# @PRE: owner/repo/from_branch/to_branch are provided.
# @POST: Returns specific branch-missing message when detected.
@@ -1599,9 +1599,9 @@ class GitService:
if not target_exists:
return f"Gitea branch not found: target branch '{to_branch}' in {owner}/{repo}"
return None
# [/DEF:backend.src.services.git_service.GitService._build_gitea_pr_404_detail:Function]
# [/DEF:_build_gitea_pr_404_detail:Function]
# [DEF:backend.src.services.git_service.GitService.create_github_repository:Function]
# [DEF:create_github_repository:Function]
# @PURPOSE: Create repository in GitHub or GitHub Enterprise.
# @PRE: PAT has repository create permission.
# @POST: Returns created repository payload.
@@ -1652,9 +1652,9 @@ class GitService:
pass
raise HTTPException(status_code=response.status_code, detail=f"GitHub API error: {detail}")
return response.json()
# [/DEF:backend.src.services.git_service.GitService.create_github_repository:Function]
# [/DEF:create_github_repository:Function]
# [DEF:backend.src.services.git_service.GitService.create_gitlab_repository:Function]
# [DEF:create_gitlab_repository:Function]
# @PURPOSE: Create repository(project) in GitLab.
# @PRE: PAT has api scope.
# @POST: Returns created repository payload.
@@ -1713,9 +1713,9 @@ class GitService:
if "full_name" not in data:
data["full_name"] = data.get("path_with_namespace") or data.get("name")
return data
# [/DEF:backend.src.services.git_service.GitService.create_gitlab_repository:Function]
# [/DEF:create_gitlab_repository:Function]
# [DEF:backend.src.services.git_service.GitService._parse_remote_repo_identity:Function]
# [DEF:_parse_remote_repo_identity:Function]
# @PURPOSE: Parse owner/repo from remote URL for Git server API operations.
# @PRE: remote_url is a valid git URL.
# @POST: Returns owner/repo tokens.
@@ -1749,9 +1749,9 @@ class GitService:
"namespace": namespace,
"full_name": f"{namespace}/{repo}",
}
# [/DEF:backend.src.services.git_service.GitService._parse_remote_repo_identity:Function]
# [/DEF:_parse_remote_repo_identity:Function]
# [DEF:backend.src.services.git_service.GitService._derive_server_url_from_remote:Function]
# [DEF:_derive_server_url_from_remote:Function]
# @PURPOSE: Build API base URL from remote repository URL without credentials.
# @PRE: remote_url may be any git URL.
# @POST: Returns normalized http(s) base URL or None when derivation is impossible.
@@ -1772,9 +1772,9 @@ class GitService:
if parsed.port:
netloc = f"{netloc}:{parsed.port}"
return f"{parsed.scheme}://{netloc}".rstrip("/")
# [/DEF:backend.src.services.git_service.GitService._derive_server_url_from_remote:Function]
# [/DEF:_derive_server_url_from_remote:Function]
# [DEF:backend.src.services.git_service.GitService.promote_direct_merge:Function]
# [DEF:promote_direct_merge:Function]
# @PURPOSE: Perform direct merge between branches in local repo and push target branch.
# @PRE: Repository exists and both branches are valid.
# @POST: Target branch contains merged changes from source branch.
@@ -1838,9 +1838,9 @@ class GitService:
"to_branch": target,
"status": "merged",
}
# [/DEF:backend.src.services.git_service.GitService.promote_direct_merge:Function]
# [/DEF:promote_direct_merge:Function]
# [DEF:backend.src.services.git_service.GitService.create_gitea_pull_request:Function]
# [DEF:create_gitea_pull_request:Function]
# @PURPOSE: Create pull request in Gitea.
# @PRE: Config and remote URL are valid.
# @POST: Returns normalized PR metadata.
@@ -1931,9 +1931,9 @@ class GitService:
"url": data.get("html_url") or data.get("url"),
"status": data.get("state") or "open",
}
# [/DEF:backend.src.services.git_service.GitService.create_gitea_pull_request:Function]
# [/DEF:create_gitea_pull_request:Function]
# [DEF:backend.src.services.git_service.GitService.create_github_pull_request:Function]
# [DEF:create_github_pull_request:Function]
# @PURPOSE: Create pull request in GitHub or GitHub Enterprise.
# @PRE: Config and remote URL are valid.
# @POST: Returns normalized PR metadata.
@@ -1987,9 +1987,9 @@ class GitService:
"url": data.get("html_url") or data.get("url"),
"status": data.get("state") or "open",
}
# [/DEF:backend.src.services.git_service.GitService.create_github_pull_request:Function]
# [/DEF:create_github_pull_request:Function]
# [DEF:backend.src.services.git_service.GitService.create_gitlab_merge_request:Function]
# [DEF:create_gitlab_merge_request:Function]
# @PURPOSE: Create merge request in GitLab.
# @PRE: Config and remote URL are valid.
# @POST: Returns normalized MR metadata.
@@ -2043,7 +2043,7 @@ class GitService:
"url": data.get("web_url") or data.get("url"),
"status": data.get("state") or "opened",
}
# [/DEF:backend.src.services.git_service.GitService.create_gitlab_merge_request:Function]
# [/DEF:create_gitlab_merge_request:Function]
# [/DEF:backend.src.services.git_service.GitService:Class]
# [/DEF:backend.src.services.git_service:Module]
# [/DEF:GitService:Class]
# [/DEF:git_service:Module]