andreoliwa / nitpick

Enforce the same settings on multiple projects
https://nitpick.readthedocs.io/
MIT License
393 stars 24 forks source link

Can't use remote style on Azure DevOps #640

Open pabepadu opened 9 months ago

pabepadu commented 9 months ago

Expected behavior

I would like to use a nitpick remote style on Azure DevOps.

The only way to get a raw file on Azure DevOps is to call APIs: https://learn.microsoft.com/en-us/rest/api/azure/devops/build/source-providers/get-file-contents?view=azure-devops-rest-7.1

This gives this kind of URL with the file path in the arguments: https://dev.azure.com/my_org/my_project/_apis/sourceProviders/Git/filecontents?repository=my_repository&path=nitpick/my_style.toml&api-version=7.1-preview.1

Current behavior

I get the below error because the last segment of the path don't have a .toml extension, then add it after filecontents:

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://dev.azure.com/my_org/my_project/_apis/sourceProviders/Git/filecontents.toml?repository=my_repository&path=nitpick%2Fmy_style.toml&api-version=7.1-preview.1

Part of the code for the tested version is here: https://github.com/andreoliwa/nitpick/blob/2148c86354dcb43545bcf2535803ce15384a7064/src/nitpick/style/fetchers/base.py#L42C13-L42C79

Steps to reproduce

  1. Set the below configuration:
    [tool.nitpick]
    style = "https://dev.azure.com/my_org/my_project/_apis/sourceProviders/Git/filecontents?repository=my_repository&path=nitpick/my_style.toml&api-version=7.1-preview.1"
  2. Run: nitpick ls

Possible Solution

Option to not normalize the url or have a specific configuration for Azure DevOps

Context

I want to use a remote nitpick style file on Azure DevOps.

Your environment