microsoft / microsoft/azure-devops-python-api

Create new git branch: azure.devops.exceptions.AzureDevOpsClientRequestError: The requested resource does not support http method 'PATCH'

Abierto
#449 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
684
Forks
218
Merge medio
8 d 10 h
PR fusionados (30 d)
1

Descripción

Background:

I'm using the azure-devops-python-api - library in order to programmatically push a commit to my Azure DevOps organization (git) repository.

The Azure DevOps REST API docs for "Update - Ref" did not help me to figure out the solution.
This discussion did not help me either.

Problem:

"The requested resource does not support http method 'PATCH'" when calling update_ref() in module azure\devops\released\git\git_client_base.py.

There is no obvious function for creating a branch, which would be called create_branch() according to the principle of least surprise.
As opposed to this Azure DevOps API, this is much more intuitively resolved in e.g. the AWS CodeCommit API.

Anyways, I would like understand what exactly goes wrong here.
The error message is very generic, I could not determine which of the inputs are the problem.

Even when I provide the filter - argument instead of being None to the target or source branch name, it throws the following error:

azure.devops.exceptions.AzureDevOpsServiceError: The only property which can be patched is isLocked.

For the sake of completeness, the short docstring of filter from the above-mentioned module:

:param str filter: The name of the branch to lock/unlock

I would also be greatful for any other way of simply creating a new branch which does not exist.


Source Code:

The code involved until invoking the git_client.update_ref() - method, is:

from azure.devops.v5_1.git.models import (
    GitRefUpdate,
)
from azure.devops.connection import Connection


release_head_commit_id = '12312314123123123213123123123'
project_name = 'project_x'
repo_name = 'project_x'
release_branch_name = 'target-branch'
feature_branch_name = 'feature-branch'
git_client = Connection(base_url=organization_url, creds=credentials).clients.get_git_client()

filter_name = None  # or feature_branch_name or release_branch_name alternatively

git_client.update_ref(
                GitRefUpdate(
                    is_locked=False,
                    name=feature_branch_name,
                    new_object_id=release_head_commit_id,
                    old_object_id='0' * 40,
                    repository_id=repo_name,
                ),
                repo_name,
                filter_name ,
                project=project_name,
                project_id=project_name,
            )

The old_object_id='0' * 40 was set like this based on this comment.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con azure/devops/released/git/git_client_base.py y el punto de entrada update_ref(); después, revisa la documentación enlazada de la API REST de Azure DevOps y la llamada proporcionada a GitRefUpdate. Determina si la creación de ramas es compatible mediante este método o requiere una ruta de API independiente, y documenta como resultado las entradas válidas o la capacidad que falta en el cliente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
azure, python
Área
api, backend
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.