Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook doesn't fire on creation or deletion of a repository that does not belong to an organisation #11766

Closed
2 of 8 tasks
JustAnotherArchivist opened this issue Jun 5, 2020 · 4 comments · Fixed by #13008

Comments

@JustAnotherArchivist
Copy link
Contributor

Steps to reproduce

  1. Set up a default webhook; in my case, I used a Gitea webhook with JSON POST, but I would be surprised if the details mattered.
  2. Create a new repository under a user, i.e. outside of an organisation.

Expected behaviour

A repository webhook event is sent to signal the creation of the new repository.

Actual behaviour

No webhook call.

Repository creation and deletion events are only executed when the repo belongs to an organisation:

if u.IsOrganization() {

if u.IsOrganization() {

While that probably made sense in the past, it doesn't mix well with default webhooks nor with the new system-wide webhooks (#10546). Those should fire on all repositories.

(I have not tested system-wide webhooks, but given the code mentioned above, it should behave the same.)

System information

  • Gitea version (or commit ref): 1.11.6
  • Git version: not relevant
  • Operating system: unknown, but I can ask if it matters
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
    • Can't test currently
  • Log gist: not relevant
@JustAnotherArchivist
Copy link
Contributor Author

#9180 is a partial duplicate of this but only mentions deletion, not creation.

@stale
Copy link

stale bot commented Aug 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label Aug 9, 2020
@JustAnotherArchivist
Copy link
Contributor Author

Yes, this is still valid.

@stale stale bot removed the issue/stale label Aug 9, 2020
@jamesorlakin
Copy link
Contributor

Default webhooks themselves don't do anything, they just are webhooks that get automatically added to fresh repos as far as I'm aware. System webhooks logically should, seeing as they're wider than just a repo in scope. I'll have a poke around to solve it for them.

However, this begs the question, should individual repos also fire a create (only if a default is defined) and delete event for their webhooks? I can't really come up with an argument for no in such a case, but I might be overlooking something.

zeripath pushed a commit that referenced this issue Oct 2, 2020
This small PR changes the webhook trigger behaviour to be more in line with what's expected. (When 'repository' events are enabled, of course)

In other words:

For system-wide or default webhooks, repository events will now trigger said webhook. Previously it had to be under an organization for create events to be visible - a tad unexpected!
Deleting a repository will now fire its own defined webhooks, not just organisational and system ones.
In order to enable the latter the webhook has to now be triggered before the actual repo undergoes deletion. I'm willing to tweak this to try and 'grab' the webhook model beforehand and trigger the webhook notifier directly afterwards, but this may make the code more complex for little benefit.

Closes #11766, #9180.
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants