feat: Implement user profile preferences for start page, Git identity, and task drawer auto-open, alongside Git server default branch configuration.

This commit is contained in:
2026-03-08 10:19:38 +03:00
parent 12d17ec35e
commit e864a9e08b
30 changed files with 2041 additions and 211 deletions

View File

@@ -411,6 +411,37 @@ class GitService:
raise HTTPException(status_code=500, detail="Failed to open local Git repository")
# [/DEF:get_repo: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.
# @RETURN: None
def configure_identity(
self,
dashboard_id: int,
git_username: Optional[str],
git_email: Optional[str],
) -> None:
with belief_scope("GitService.configure_identity"):
normalized_username = str(git_username or "").strip()
normalized_email = str(git_email or "").strip()
if not normalized_username or not normalized_email:
return
repo = self.get_repo(dashboard_id)
try:
with repo.config_writer(config_level="repository") as config_writer:
config_writer.set_value("user", "name", normalized_username)
config_writer.set_value("user", "email", normalized_email)
logger.info(
"[configure_identity][Action] Applied repository-local git identity for dashboard %s",
dashboard_id,
)
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:configure_identity:Function]
# [DEF:list_branches:Function]
# @PURPOSE: List all branches for a dashboard's repository.
# @PRE: Repository for dashboard_id exists.
@@ -601,6 +632,21 @@ class GitService:
def pull_changes(self, dashboard_id: int):
with belief_scope("GitService.pull_changes"):
repo = self.get_repo(dashboard_id)
# Check for unfinished merge (MERGE_HEAD exists)
merge_head_path = os.path.join(repo.git_dir, "MERGE_HEAD")
if os.path.exists(merge_head_path):
logger.warning(f"[pull_changes][Action] Unfinished merge detected for dashboard {dashboard_id}")
raise HTTPException(
status_code=409,
detail=(
"В репозитории есть незавершённое слияние. "
"Пожалуйста, завершите или отмените слияние вручную: "
"1) Разрешите конфликты и выполните коммит, или "
"2) Выполните 'git merge --abort' для отмены слияния."
),
)
try:
origin = repo.remote(name='origin')
current_branch = repo.active_branch.name