weblate icon indicating copy to clipboard operation
weblate copied to clipboard

Support Commit Hooks for Azure Repositories connected via ssh

Open likemike91 opened this issue 4 years ago • 6 comments

Is your feature request related to a problem? If so, please describe. Right now it's only possible to send commit hooks from Azure Repositories that are cloned via HTTP(S) but not the ones which are cloned via SSH like for example it is supported for hooks from GitHub.

Describe the solution you'd like The hooks.py view should use the same mechanism to provide possible repositories that it used e.g. for GitHub (GITHUB_REPOS variable) by constructing possible URLs.

Describe alternatives you've considered Cloning would be possible via HTTP(S) but SSH based access is more convenient e.g. in terms of expiry date since Azure DevOps PAT tokens (used to clone the git repository) can only have a max token lifetime of one year.

likemike91 avatar Nov 22 '20 09:11 likemike91

I already opened a StackOverflow question to provide a list of all possible Azure Repositories URL's to help with implementation: https://stackoverflow.com/questions/64952871/list-of-all-possible-azure-repos-urls

likemike91 avatar Nov 22 '20 10:11 likemike91

The matching falls back to repos ending with same URL, that should cover most cases. But exposing correct URLs could help in some situations.

nijel avatar Nov 22 '20 11:11 nijel

@nijel Did I get it right that normally ssh based access should work already?

I configured the repository with the following url in Weblate: [email protected]:v3/{OrganizationName}/{ProjectName}/{RepositoryName}

And the Webhook from Azure Repos sends the following repository URL (The value of "/resource/repository/remoteUrl" in the request body): https://dev.azure.com/{OrganizationName}/{ProjectName}/_git/{RepositoryName}

And unfortunately I get

{
    "status": "failure",
    "message": "No matching repositories found!"
}

likemike91 avatar Nov 27 '20 13:11 likemike91

I have no knowledge of how Azure constructs URLs, but it does work for most of the other services which have similar URLs on SSH and HTTPS.

You describe that Azure does this differently and injects _git somewhere in the HTTPS URL what is not present in the SSH URL, so this logic will not help there.

nijel avatar Nov 27 '20 15:11 nijel

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

github-actions[bot] avatar Dec 04 '20 13:12 github-actions[bot]

Can confirm that this is still an issue.

My translation component is set as: [email protected]:v3/mycompany/MyClient%20-%20CalculationTool/MyClient%20-%20CalculationTool

but when the hook get sent, I read the following in the logs: received Azure notification on repository MyClient - CalculationTool, URL https://dev.azure.com/mycompany/MyClient%20-%20CalculationTool/_git/MyClient%20-%20CalculationTool, branch master, 0 matching components, 0 to process, 0 linked

I'll be happy to provide more details if needed.

samusaran avatar Oct 24 '23 12:10 samusaran

I'm facing the same issue, has this be solved?

gilamarko avatar Mar 07 '24 12:03 gilamarko

Using space in the URL as well? Can you share Azure webhook payload?

nijel avatar Mar 07 '24 13:03 nijel

My Weblate is configured with SSH, (HTTPS works fine, but I want to avoid having to renew the credentials every year lets say). Where should I put the space? On the Azure Webhook?

gilamarko avatar Mar 07 '24 13:03 gilamarko

https://github.com/WeblateOrg/weblate/issues/4894#issuecomment-1777145047 shows repository URL with a space, what, I believe, was the problem there. Can you share Azure webhook payload?

nijel avatar Mar 07 '24 15:03 nijel

Yes indeed my Project name has spaces, adjusted the payload with random UUIDs just for the example.

{
    "subscriptionId": "8efced88-c100-41a3-96ca-ee29eb1f877a",
    "notificationId": 2,
    "id": "8efced88-c100-41a3-96ca-ee29eb1f877a",
    "eventType": "git.push",
    "publisherId": "tfs",
    "message": {
        "text": "Dev User pushed updates to My-Fe-App:dev\r\n(https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/#version=GBdev)",
        "html": "Dev User pushed updates to <a href=\"https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/\">My-Fe-App</a>:<a href=\"https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/#version=GBdev\">dev</a>",
        "markdown": "Dev User pushed updates to [My-Fe-App](https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/):[dev](https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/#version=GBdev)"
    },
    "detailedMessage": {
        "text": "Dev User pushed a commit to My-Fe-App:dev\r\n - Add translation from dev ed967ae1 (https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/commit/ed967ae1dd2e97e3bdadf78281c5489c47f971e6)",
        "html": "Dev User pushed a commit to <a href=\"https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/\">My-Fe-App</a>:<a href=\"https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/#version=GBdev\">dev</a>\r\n<ul>\r\n<li>Add translation from dev <a href=\"https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/commit/ed967ae1dd2e97e3bdadf78281c5489c47f971e6\">ed967ae1</a></li>\r\n</ul>",
        "markdown": "Dev User pushed a commit to [My-Fe-App](https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/):[dev](https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/#version=GBdev)\r\n* Add translation from dev [ed967ae1](https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App/commit/ed967ae1dd2e97e3bdadf78281c5489c47f971e6)"
    },
    "resource": {
        "refUpdates": [
            {
                "name": "refs/heads/dev",
                "oldObjectId": "8efced88-c100-41a3-96ca-ee29eb1f877a",
                "newObjectId": "8efced88-c100-41a3-96ca-ee29eb1f877a"
            }
        ],
        "repository": {
            "id": "8efced88-c100-41a3-96ca-ee29eb1f877a",
            "name": "My-Fe-App",
            "url": "https://dev.azure.com/MyOrg/_apis/git/repositories/8efced88-c100-41a3-96ca-ee29eb1f877a",
            "project": {
                "id": "8efced88-c100-41a3-96ca-ee29eb1f877a",
                "name": "NextGen B2B Shop",
                "url": "https://dev.azure.com/MyOrg/_apis/projects/8efced88-c100-41a3-96ca-ee29eb1f877a",
                "state": "wellFormed",
                "visibility": "unchanged",
                "lastUpdateTime": "0001-01-01T00:00:00"
            },
            "defaultBranch": "refs/heads/main",
            "remoteUrl": "https://dev.azure.com/MyOrg/My%20Special%20Shop/_git/My-Fe-App"
        },
        "pushedBy": {
            "displayName": "Dev User",
            "url": "https://spsprodweu5.vssps.visualstudio.com/8efced88-c100-41a3-96ca-ee29eb1f877a/_apis/Identities/8efced88-c100-41a3-96ca-ee29eb1f877a",
            "_links": {
                "avatar": {
                    "href": "https://dev.azure.com/MyOrg/_apis/GraphProfile/MemberAvatars/aad.NzZjOWE5ODgtN2E1OS03NDYwLWIwOGUtZjJhODE3NDVkMjdk"
                }
            },
            "id": "76c9a988-7a59-6460-b08e-f2a81745d27d",
            "uniqueName": "[email protected]",
            "imageUrl": "https://dev.azure.com/MyOrg/_api/_common/identityImage?id=8efced88-c100-41a3-96ca-ee29eb1f877a",
            "descriptor": "aad.NzZjOWE5ODgtN2E1OS03NDYwLWIwOGUtZjJhODE3NDVkMjdk"
        },
        "pushId": 2952,
        "date": "2024-03-07T12:27:01.2266022Z",
        "url": "https://dev.azure.com/MyOrg/_apis/git/repositories/8efced88-c100-41a3-96ca-ee29eb1f877a/pushes/2952",
        "_links": {
            "self": {
                "href": "https://dev.azure.com/MyOrg/_apis/git/repositories/8efced88-c100-41a3-96ca-ee29eb1f877a/pushes/2952"
            },
            "repository": {
                "href": "https://dev.azure.com/MyOrg/8efced88-c100-41a3-96ca-ee29eb1f877a/_apis/git/repositories/8efced88-c100-41a3-96ca-ee29eb1f877a"
            },
            "commits": {
                "href": "https://dev.azure.com/MyOrg/_apis/git/repositories/8efced88-c100-41a3-96ca-ee29eb1f877a/pushes/2952/commits"
            },
            "pusher": {
                "href": "https://spsprodweu5.vssps.visualstudio.com/8efced88-c100-41a3-96ca-ee29eb1f877a/_apis/Identities/76c9a988-7a59-6460-b08e-f2a81745d27d"
            },
            "refs": {
                "href": "https://dev.azure.com/MyOrg/8efced88-c100-41a3-96ca-ee29eb1f877a/_apis/git/repositories/8efced88-c100-41a3-96ca-ee29eb1f877a/refs/heads/dev"
            }
        }
    },
    "resourceVersion": "1.0",
    "resourceContainers": {
        "collection": {
            "id": "8efced88-c100-41a3-96ca-ee29eb1f877a",
            "baseUrl": "https://dev.azure.com/MyOrg/"
        },
        "account": {
            "id": "8efced88-c100-41a3-96ca-ee29eb1f877a",
            "baseUrl": "https://dev.azure.com/MyOrg/"
        },
        "project": {
            "id": "8efced88-c100-41a3-96ca-ee29eb1f877a",
            "baseUrl": "https://dev.azure.com/MyOrg/"
        }
    },
    "createdDate": "8efced88-c100-41a3-96ca-ee29eb1f877a"
}

gilamarko avatar Mar 08 '24 09:03 gilamarko

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

github-actions[bot] avatar Mar 11 '24 16:03 github-actions[bot]