feat(webhook): fire repository event on repo rename (#38641)

Repository create and delete already fire `repository` webhooks, rename
did not. This adds the `renamed` action with `changes.name.from`
carrying the previous name, and renders it in the chat converters.

Actions workflows are unaffected, they still do not trigger on rename.

AI assistance was used for the implementation and tests.

Fixes https://github.com/go-gitea/gitea/issues/34891.
Co-authored-by: roman s <roman.sukach@dust-labs.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
roman.s
2026-07-31 14:31:17 +03:00
committed by GitHub
parent 7ca64566f5
commit 38b07d0c29
14 changed files with 70 additions and 1 deletions
+14
View File
@@ -859,6 +859,20 @@ func Test_WebhookRepository(t *testing.T) {
assert.Equal(t, "org3", payloads[0].Organization.UserName)
assert.Equal(t, "repo_new", payloads[0].Repository.Name)
assert.Equal(t, "org3/repo_new", payloads[0].Repository.FullName)
// 4. rename the repository and validate the webhook is triggered again
newName := "repo_renamed"
req := NewRequestWithJSON(t, "PATCH", "/api/v1/repos/org3/repo_new", &api.EditRepoOption{
Name: &newName,
}).AddTokenAuth(getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository))
MakeRequest(t, req, http.StatusOK)
require.Len(t, payloads, 2)
assert.Equal(t, api.HookRepoRenamed, payloads[1].Action)
assert.Equal(t, newName, payloads[1].Repository.Name)
assert.Equal(t, "org3/"+newName, payloads[1].Repository.FullName)
require.NotNil(t, payloads[1].Changes.Name)
assert.Equal(t, "repo_new", payloads[1].Changes.Name.From)
})
}