From 34205e13b277185ab4289c3576ee5b809633bd34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogi=20Napoleon=20Wennerstr=C3=B8m?= Date: Tue, 14 Nov 2023 13:44:10 +0100 Subject: [PATCH] Renamed Devops to Azure DevOps --- docs/admin/config.rst | 14 ++-- docs/admin/continuous.rst | 82 ++++++++++++------------ docs/admin/install/docker.rst | 12 ++-- docs/snippets/vcs-credentials-devops.rst | 59 ----------------- docs/vcs.rst | 22 +++---- weblate/addons/git.py | 2 +- weblate/settings_docker.py | 4 +- weblate/settings_example.py | 4 +- weblate/trans/forms.py | 2 +- weblate/vcs/git.py | 20 +++--- weblate/vcs/models.py | 6 +- weblate/vcs/tests/test_vcs.py | 12 ++-- 12 files changed, 90 insertions(+), 149 deletions(-) delete mode 100644 docs/snippets/vcs-credentials-devops.rst diff --git a/docs/admin/config.rst b/docs/admin/config.rst index 8aee63c149a2..ca06240a31d5 100644 --- a/docs/admin/config.rst +++ b/docs/admin/config.rst @@ -835,9 +835,9 @@ List for credentials for Bitbucket servers. :ref:`vcs-bitbucket-server`, `Bitbucket: HTTP access token `_ -.. setting:: DEVOPS_CREDENTIALS +.. setting:: AZURE_DEVOPS_CREDENTIALS -DEVOPS_CREDENTIALS +AZURE_DEVOPS_CREDENTIALS ------------------ .. versionadded:: 5.2 @@ -846,7 +846,7 @@ List for credentials for Azure DevOps servers. .. code-block:: python - DEVOPS_CREDENTIALS = { + AZURE_DEVOPS_CREDENTIALS = { "dev.azure.com": { "username": "project-name", "token": "your-api-token", @@ -861,7 +861,7 @@ example GitHub API is accessed as ``api.github.com``. The following configuration is available for each host: ``username`` - The name of the DevOps project. This is not the repository name. + The name of the Azure DevOps project. This is not the repository name. ``organization`` The name of the organization of the project. ``workItemIds`` @@ -874,8 +874,8 @@ Additional settings not described here can be found at :ref:`settings-credential .. seealso:: - :ref:`vcs-devops`, - `DevOps: Personal access token `_ + :ref:`vcs-azure-devops`, + `Azure DevOps: Personal access token `_ .. setting:: GOOGLE_ANALYTICS_ID @@ -1866,7 +1866,7 @@ VCS_API_DELAY Configures minimal delay in seconds between third-party API calls in :ref:`vcs-github`, :ref:`vcs-gitlab`, :ref:`vcs-gitea`, :ref:`vcs-pagure`, and -:ref:`vcs-devops`. +:ref:`vcs-azure-devops`. This rate-limits API calls from Weblate to these services to avoid overloading them. diff --git a/docs/admin/continuous.rst b/docs/admin/continuous.rst index b426156b90bc..423921ad060d 100644 --- a/docs/admin/continuous.rst +++ b/docs/admin/continuous.rst @@ -330,49 +330,49 @@ under :guilabel:`Repository maintenance` or using API via :option:`wlc push`. The push options differ based on the :ref:`vcs` used, more details are found in that chapter. In case you do not want direct pushes by Weblate, there is support for -:ref:`vcs-github`, :ref:`vcs-gitlab`, :ref:`vcs-gitea`, :ref:`vcs-pagure`, :ref`vcs-devops` -pull requests or :ref:`vcs-gerrit` reviews, you can activate these by choosing -:guilabel:`GitHub`, :guilabel:`GitLab`, :guilabel:`Gitea`, :guilabel:`Gerrit`, -:guilabel:`DevOps`, or :guilabel:`Pagure` as :ref:`component-vcs` in :ref:`component`. +:ref:`vcs-github`, :ref:`vcs-gitlab`, :ref:`vcs-gitea`, :ref:`vcs-pagure`, +:ref:`vcs-azure-devops` pull requests or :ref:`vcs-gerrit` reviews, you can activate these by +choosing :guilabel:`GitHub`, :guilabel:`GitLab`, :guilabel:`Gitea`, :guilabel:`Gerrit`, +:guilabel:`Azure DevOps`, or :guilabel:`Pagure` as :ref:`component-vcs` in :ref:`component`. Overall, following options are available with Git, Mercurial, GitHub, GitLab, -Gitea, Pagure, and DevOps: - -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Desired setup | :ref:`component-vcs` | :ref:`component-push` | :ref:`component-push_branch` | -+===================================+===============================+===============================+===============================+ -| No push | :ref:`vcs-git` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Push directly | :ref:`vcs-git` | SSH URL | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Push to separate branch | :ref:`vcs-git` | SSH URL | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| No push | :ref:`vcs-mercurial` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Push directly | :ref:`vcs-mercurial` | SSH URL | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Push to separate branch | :ref:`vcs-mercurial` | SSH URL | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| GitHub pull request from fork | :ref:`vcs-github` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| GitHub pull request from branch | :ref:`vcs-github` | SSH URL [#empty]_ | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| GitLab merge request from fork | :ref:`vcs-gitlab` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| GitLab merge request from branch | :ref:`vcs-gitlab` | SSH URL [#empty]_ | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Gitea merge request from fork | :ref:`vcs-gitea` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Gitea merge request from branch | :ref:`vcs-gitea` | SSH URL [#empty]_ | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Pagure merge request from fork | :ref:`vcs-pagure` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| Pagure merge request from branch | :ref:`vcs-pagure` | SSH URL [#empty]_ | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| DevOps pull request from fork | :ref:`vcs-devops` | `empty` | `empty` | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ -| DevOps pull request from branch | :ref:`vcs-devops` | SSH URL [#empty]_ | Branch name | -+-----------------------------------+-------------------------------+-------------------------------+-------------------------------+ +Gitea, Pagure, and Azure DevOps: + ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Desired setup | :ref:`component-vcs` | :ref:`component-push` | :ref:`component-push_branch` | ++=========================================+===============================+===============================+===============================+ +| No push | :ref:`vcs-git` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Push directly | :ref:`vcs-git` | SSH URL | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Push to separate branch | :ref:`vcs-git` | SSH URL | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| No push | :ref:`vcs-mercurial` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Push directly | :ref:`vcs-mercurial` | SSH URL | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Push to separate branch | :ref:`vcs-mercurial` | SSH URL | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| GitHub pull request from fork | :ref:`vcs-github` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| GitHub pull request from branch | :ref:`vcs-github` | SSH URL [#empty]_ | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| GitLab merge request from fork | :ref:`vcs-gitlab` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| GitLab merge request from branch | :ref:`vcs-gitlab` | SSH URL [#empty]_ | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Gitea merge request from fork | :ref:`vcs-gitea` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Gitea merge request from branch | :ref:`vcs-gitea` | SSH URL [#empty]_ | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Pagure merge request from fork | :ref:`vcs-pagure` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Pagure merge request from branch | :ref:`vcs-pagure` | SSH URL [#empty]_ | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Azure DevOps pull request from fork | :ref:`vcs-azure-devops` | `empty` | `empty` | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ +| Azure DevOps pull request from branch | :ref:`vcs-azure-devops` | SSH URL [#empty]_ | Branch name | ++-----------------------------------------+-------------------------------+-------------------------------+-------------------------------+ .. [#empty] Can be empty in case :ref:`component-repo` supports pushing. diff --git a/docs/admin/install/docker.rst b/docs/admin/install/docker.rst index dabe16ac4eea..430e4437a8db 100644 --- a/docs/admin/install/docker.rst +++ b/docs/admin/install/docker.rst @@ -1076,13 +1076,13 @@ Or the path to a file containing the Python dictionary: .. seealso:: :ref:`Configuring code hosting credentials in Docker ` -.. envvar:: WEBLATE_DEVOPS_USERNAME -.. envvar:: WEBLATE_DEVOPS_ORGANIZATION -.. envvar:: WEBLATE_DEVOPS_TOKEN -.. envvar:: WEBLATE_DEVOPS_HOST -.. envvar:: WEBLATE_DEVOPS_CREDENTIALS +.. envvar:: WEBLATE_AZURE_DEVOPS_USERNAME +.. envvar:: WEBLATE_AZURE_DEVOPS_ORGANIZATION +.. envvar:: WEBLATE_AZURE_DEVOPS_TOKEN +.. envvar:: WEBLATE_AZURE_DEVOPS_HOST +.. envvar:: WEBLATE_AZURE_DEVOPS_CREDENTIALS - Configures :ref:`vcs-devops` by changing :setting:`DEVOPS_CREDENTIALS`. + Configures :ref:`vcs-azure-devops` by changing :setting:`AZURE_DEVOPS_CREDENTIALS`. .. seealso:: :ref:`Configuring code hosting credentials in Docker ` diff --git a/docs/snippets/vcs-credentials-devops.rst b/docs/snippets/vcs-credentials-devops.rst deleted file mode 100644 index eea353919214..000000000000 --- a/docs/snippets/vcs-credentials-devops.rst +++ /dev/null @@ -1,59 +0,0 @@ -The configuration dictionary consists of credentials defined for each API host. -The API host might be different from what you use in the web browser, for -example GitHub API is accessed as ``api.github.com``. - -The following configuration is available for each host: - -``username`` - The name of the DevOps project. This is not the repository name. -``organization`` - The name of the organization of the project. -``workItemIds`` - An optional list of work items IDs from your organization. When provided - new pull requests will have these attached. -``token`` - API token for the API user, required. -``scheme`` - .. versionadded:: 4.18 - - Scheme override. Weblate attempts to parse scheme from the repository URL - and falls backs to ``https``. If you are running the API server internally, - you might want to use ``http`` instead, but consider security. - -.. hint:: - - In the Docker container, the credentials can be configured in four variables - and the credentials are built out of that. An example configuration might - look like: - - .. code-block:: shell - - WEBLATE_DEVOPS_USERNAME=project-name - WEBLATE_DEVOPS_ORGANIZATION=org-name - WEBLATE_DEVOPS_TOKEN=api-token - WEBLATE_DEVOPS_HOST=dev.azure.com - - Will be used as: - - .. code-block:: python - - DEVOPS_CREDENTIALS = { - "dev.azure.com": { - "username": "project-name", - "token": "api-token", - "organization": "org-name", - } - } - - Alternatively the Python dictionary can be provided as a string: - - .. code-block:: shell - - WEBLATE_DEVOPS_CREDENTIALS='{ "dev.azure.com": { "username": "project-name", "token": "api-token", "organization": "org-name" } }' - - Or the path to a file containing the Python dictionary: - - .. code-block:: shell - - echo '{ "dev.azure.com": { "username": "project-name", "token": "api-token", "organization": "org-name" } }' > /path/to/devops-credentials - WEBLATE_DEVOPS_CREDENTIALS_FILE='/path/to/devops-credentials' diff --git a/docs/vcs.rst b/docs/vcs.rst index e5fb7e3159ad..a0ee287c8f8f 100644 --- a/docs/vcs.rst +++ b/docs/vcs.rst @@ -5,7 +5,7 @@ Version control integration Weblate currently supports :ref:`vcs-git` (with extended support for :ref:`vcs-github`, :ref:`vcs-gitlab`, :ref:`vcs-gitea`, :ref:`vcs-gerrit`, -:ref:`vcs-git-svn`, :ref:`vcs-bitbucket-server`, and :ref:`vcs-devops`) and +:ref:`vcs-git-svn`, :ref:`vcs-bitbucket-server`, and :ref:`vcs-azure-devops`) and :ref:`vcs-mercurial` as version control back-ends. .. _vcs-repos: @@ -460,29 +460,29 @@ pushing them directly to the repository. The Gerrit documentation has the details on the configuration necessary to set up such repositories. -.. _vcs-devops: -.. _devops-push: +.. _vcs-azure-devops: +.. _azure-devops-push: -DevOps pull requests --------------------- +Azure DevOps pull requests +-------------------------- -This adds a thin layer atop :ref:`vcs-git` using the `DevOps API`_ to allow pushing +This adds a thin layer atop :ref:`vcs-git` using the `Azure DevOps API`_ to allow pushing translation changes as pull requests, instead of pushing directly to the repository. :ref:`vcs-git` pushes changes directly to a repository, while -:ref:`vcs-devops` creates pull requests. +:ref:`vcs-azure-devops` creates pull requests. The latter is not needed for merely accessing Git repositories. -You need to configure API credentials (:setting:`DEVOPS_CREDENTIALS`) in the +You need to configure API credentials (:setting:`AZURE_DEVOPS_CREDENTIALS`) in the Weblate settings to make this work. Once configured, you will see a -:guilabel:`DevOps` option when selecting :ref:`component-vcs`. +:guilabel:`Azure DevOps` option when selecting :ref:`component-vcs`. .. seealso:: :ref:`push-changes`, - :setting:`DEVOPS_CREDENTIALS` + :setting:`AZURE_DEVOPS_CREDENTIALS` -.. _DevOps API: https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-7.2 +.. _Azure DevOps API: https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-7.2 .. _git-review: https://pypi.org/project/git-review/ diff --git a/weblate/addons/git.py b/weblate/addons/git.py index ac0e8ad5188e..4845a8518403 100644 --- a/weblate/addons/git.py +++ b/weblate/addons/git.py @@ -29,7 +29,7 @@ class GitSquashAddon(BaseAddon): "gitlab", "git-force-push", "gitea", - "devops", + "azure_devops", } } events = (EVENT_POST_COMMIT,) diff --git a/weblate/settings_docker.py b/weblate/settings_docker.py index 640cad419ffa..4905c27d567c 100644 --- a/weblate/settings_docker.py +++ b/weblate/settings_docker.py @@ -216,9 +216,9 @@ # Please see the documentation for more details. GITHUB_CREDENTIALS = get_env_credentials("GITHUB") -# DevOps username, token, and organization for sending pull requests. +# Azure DevOps username, token, and organization for sending pull requests. # Please see the documentation for more details. -DEVOPS_CREDENTIALS = get_env_credentials("DEVOPS") +AZURE_DEVOPS_CREDENTIALS = get_env_credentials("AZURE_DEVOPS") # GitLab username and token for sending merge requests. # Please see the documentation for more details. diff --git a/weblate/settings_example.py b/weblate/settings_example.py index 040169335be4..ea8c9077eb58 100644 --- a/weblate/settings_example.py +++ b/weblate/settings_example.py @@ -200,9 +200,9 @@ # Please see the documentation for more details. GITHUB_CREDENTIALS = {} -# DevOps username and token for sending pull requests. +# Azure DevOps username and token for sending pull requests. # Please see the documentation for more details. -DEVOPS_CREDENTIALS = {} +AZURE_DEVOPS_CREDENTIALS = {} # GitLab username and token for sending merge requests. # Please see the documentation for more details. diff --git a/weblate/trans/forms.py b/weblate/trans/forms.py index 400f0426232d..de82bf1d8794 100644 --- a/weblate/trans/forms.py +++ b/weblate/trans/forms.py @@ -1586,7 +1586,7 @@ def __init__(self, request, *args, **kwargs): "pagure", "local", "git-force-push", - "devops", + "azure_devops", ) if self.instance.vcs not in vcses: vcses = (self.instance.vcs,) diff --git a/weblate/vcs/git.py b/weblate/vcs/git.py index 7128c858b099..dbd717b21a68 100644 --- a/weblate/vcs/git.py +++ b/weblate/vcs/git.py @@ -1084,30 +1084,30 @@ def raise_for_response(cls, response: requests.Response): """ Raises :class:`HTTPError`, if one occurred. - Some providers (DevOps for instance) respond with codes in the 2XX range + Some providers (Azure DevOps for instance) respond with codes in the 2XX range even though the response was an error. This method exists to let the inheritors override it if they have special cases. """ response.raise_for_status() -class DevopsRepository(GitMergeRequestBase): - name = gettext_lazy("DevOps pull request") - identifier = "devops" +class AzureDevOpsRepository(GitMergeRequestBase): + name = gettext_lazy("Azure DevOps pull request") + identifier = "azure_devops" _version = None API_TEMPLATE = "{scheme}://{host}/{owner}/_apis/git/repositories/{slug}" ORG_API_TEMPLATE = "{scheme}://{host}/{org}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1" REQUIRED_CONFIG = {"username", "token", "organization"} OPTIONAL_CONFIG = {"scheme", "workItemIds"} push_label = gettext_lazy( - "This will push changes and create a DevOps pull request." + "This will push changes and create a Azure DevOps pull request." ) @classmethod def raise_for_response(cls, response: requests.Response): super().raise_for_response(response) - # DevOps returns 203 when the token is invalid + # Azure DevOps returns 203 when the token is invalid if response.status_code == 203: raise RepositoryError(0, "Invalid token") @@ -1266,11 +1266,11 @@ def create_pull_request( def __get_forked_id(self, credentials: dict, remote: str) -> str: """ - Returns ID of the forked DevOps repository. + Returns ID of the forked Azure DevOps repository. - To send a PR to DevOps via API with a fork, one needs to send request - a request with the ID of the forked repository (unlike others, where - the name is enough). + To send a PR to Azure DevOps via API with a fork, one needs to send + request a request with the ID of the forked repository (unlike others, + where the name is enough). """ cmd = ["remote", "get-url", "--push", remote] fork_remotes = self.execute(cmd, needs_lock=False, merge_err=False).splitlines() diff --git a/weblate/vcs/models.py b/weblate/vcs/models.py index 4964fa7fdac4..7e8a83fb85b5 100644 --- a/weblate/vcs/models.py +++ b/weblate/vcs/models.py @@ -13,7 +13,7 @@ class VCSConf(AppConf): "weblate.vcs.git.GitWithGerritRepository", "weblate.vcs.git.SubversionRepository", "weblate.vcs.git.GithubRepository", - "weblate.vcs.git.DevopsRepository", + "weblate.vcs.git.AzureDevOpsRepository", "weblate.vcs.git.GiteaRepository", "weblate.vcs.git.GitLabRepository", "weblate.vcs.git.PagureRepository", @@ -28,8 +28,8 @@ class VCSConf(AppConf): # GitHub username for sending pull requests GITHUB_CREDENTIALS = {} - # GitHub username for sending pull requests - DEVOPS_CREDENTIALS = {} + # Azure DevOps username for sending pull requests + AZURE_DEVOPS_CREDENTIALS = {} # GitLab username for sending merge requests GITLAB_CREDENTIALS = {} diff --git a/weblate/vcs/tests/test_vcs.py b/weblate/vcs/tests/test_vcs.py index 7b115614eb62..c374c8ec0758 100644 --- a/weblate/vcs/tests/test_vcs.py +++ b/weblate/vcs/tests/test_vcs.py @@ -23,7 +23,7 @@ from weblate.vcs.base import RepositoryError from weblate.vcs.git import ( BitbucketServerRepository, - DevopsRepository, + AzureDevOpsRepository, GiteaRepository, GitForcePushRepository, GithubRepository, @@ -37,7 +37,7 @@ from weblate.vcs.mercurial import HgRepository -class DevopsFakeRepository(DevopsRepository): +class AzureDevOpsFakeRepository(AzureDevOpsRepository): _is_supported = None _version = None @@ -676,7 +676,7 @@ def test_pull_request_exists(self, branch=""): @override_settings( - DEVOPS_CREDENTIALS={ + AZURE_DEVOPS_CREDENTIALS={ "dev.azure.com": { "username": "test", "token": "token", @@ -684,8 +684,8 @@ def test_pull_request_exists(self, branch=""): } } ) -class VCSDevOpsTest(VCSGitUpstreamTest): - _class = DevopsFakeRepository +class VCSAzureDevOpsTest(VCSGitUpstreamTest): + _class = AzureDevOpsFakeRepository _vcs = "git" _sets_push = False _mock_push_to_fork = None @@ -837,7 +837,7 @@ def test_pull_request_exists(self, branch=""): super().test_push(branch) @override_settings( - DEVOPS_CREDENTIALS={ + AZURE_DEVOPS_CREDENTIALS={ "dev.azure.com": { "username": "test", "token": "token",