microsoft / microsoft/azure-devops-python-api

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

Ouverte
#449 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Python
Étoiles
684
Forks
218
Merge moyen
8 j 10 h
PR mergées (30 j)
1

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par azure/devops/released/git/git_client_base.py et le point d’entrée update_ref(), puis examinez la documentation liée de l’API REST Azure DevOps ainsi que l’appel GitRefUpdate fourni. Déterminez si la création de branches est prise en charge par cette méthode ou si elle nécessite un chemin d’API distinct, et documentez comme résultat les entrées valides ou la capacité manquante du client.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
azure, python
Domaine
api, backend
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.