Coverage for app/venv/lib/python3.14/site-packages/weblate/vcs/models.py: 90%
43 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
1# Copyright © Michal Čihař <michal@weblate.org>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5from __future__ import annotations
7from typing import ClassVar
9from appconf import AppConf
10from django.utils.functional import cached_property
12from weblate.utils.classloader import ClassLoader
14from .base import Repository
17class VCSConf(AppConf):
18 VCS_BACKENDS = (
19 "weblate.vcs.git.GitRepository",
20 "weblate.vcs.git.GitWithGerritRepository",
21 "weblate.vcs.git.SubversionRepository",
22 "weblate.vcs.git.GithubRepository",
23 "weblate.vcs.git.AzureDevOpsRepository",
24 "weblate.vcs.git.GiteaRepository",
25 "weblate.vcs.git.GitLabRepository",
26 "weblate.vcs.git.PagureRepository",
27 "weblate.vcs.git.LocalRepository",
28 "weblate.vcs.git.GitForcePushRepository",
29 "weblate.vcs.git.BitbucketServerRepository",
30 "weblate.vcs.git.BitbucketCloudRepository",
31 "weblate.vcs.mercurial.HgRepository",
32 )
33 VCS_CLONE_DEPTH = 1
34 VCS_API_DELAY = 10
35 VCS_FILE_PROTOCOL = False
37 # GitHub username for sending pull requests
38 GITHUB_CREDENTIALS: ClassVar[dict] = {}
40 # Azure DevOps username for sending pull requests
41 AZURE_DEVOPS_CREDENTIALS: ClassVar[dict] = {}
43 # GitLab username for sending merge requests
44 GITLAB_CREDENTIALS: ClassVar[dict] = {}
46 # Pagure username for sending merge requests
47 PAGURE_CREDENTIALS: ClassVar[dict] = {}
49 # Gitea username for sending pull requests
50 GITEA_CREDENTIALS: ClassVar[dict] = {}
52 # Bitbucket username for sending pull requests
53 BITBUCKETSERVER_CREDENTIALS: ClassVar[dict] = {}
55 # Bitbucket username for sending pull requests
56 BITBUCKETCLOUD_CREDENTIALS: ClassVar[dict] = {}
58 SSH_EXTRA_ARGS = ""
60 class Meta:
61 prefix = ""
64class VcsClassLoader(ClassLoader):
65 def __init__(self) -> None:
66 super().__init__("VCS_BACKENDS", construct=False, base_class=Repository)
68 def load_data(self):
69 result = super().load_data()
71 for key, vcs in list(result.items()):
72 try:
73 version = vcs.get_version()
74 except Exception as error:
75 supported = False
76 self.errors[vcs.name] = str(error)
77 else:
78 supported = vcs.is_supported()
79 if not supported: 79 ↛ 80line 79 didn't jump to line 80 because the condition on line 79 was never true
80 self.errors[vcs.name] = f"Outdated version: {version}"
82 if not supported or not vcs.is_configured():
83 result.pop(key)
85 return result
87 @cached_property
88 def git_based(self) -> set[str]:
89 from weblate.vcs.git import GitRepository
91 return {
92 vcs.get_identifier()
93 for vcs in self.values()
94 if issubclass(vcs, GitRepository)
95 }
98# Initialize VCS list
99VCS_REGISTRY = VcsClassLoader()