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

Webhooks for repo creation/deletion #1663

Merged
merged 4 commits into from
Sep 3, 2017

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented May 4, 2017

Allow organizations to have webhooks that are triggered by repository creation/deletion. Partially addresses #2113.

Depends on go-gitea/go-sdk#55 (merged)

@lunny lunny added the modifies/api This PR adds API routes or modifies them label May 4, 2017
<div class="seven wide column">
<div class="field">
<div class="ui checkbox">
<input class="hidden" name="repository" type="checkbox" tabindex="0" {{if .Webhook.PullRequest}}checked{{end}}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Webhook.Repository?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@ethantkoenig
Copy link
Member Author

Rebased to resolve conflicts.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 6, 2017
@ethantkoenig ethantkoenig force-pushed the etk/org_webhook branch 2 times, most recently from 0bfaa20 to 66eebe8 Compare May 25, 2017 18:07
@stephenc
Copy link

Will be great to see this merged so I can add support to the https://github.com/jenkinsci/gitea-plugin

models/repo.go Outdated
Organization: u.APIFormat(),
Sender: doer.APIFormat(),
}); err != nil {
return fmt.Errorf("PrepareWebhooks: %v", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not go HookQueue.Add(repo.ID) here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

models/repo.go Outdated
@@ -1246,6 +1246,13 @@ func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) {
return fmt.Errorf("getOwnerTeam: %v", err)
} else if err = t.addRepository(e, repo); err != nil {
return fmt.Errorf("addRepository: %v", err)
} else if err = PrepareWebhooks(repo, HookEventRepository, &api.RepositoryPayload{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result database table lock on sqlite since we have a transaction here and another in PrepareWebhooks. It seems you have to create a prepareWebhooks(e Engine... method to avoid that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@lunny
Copy link
Member

lunny commented Aug 30, 2017

@ethantkoenig Still fail in sqlite on function prepareWebhook when call CreateHookTask.

@ethantkoenig
Copy link
Member Author

@lunny Good catch, fixed

@lunny
Copy link
Member

lunny commented Aug 30, 2017

@ethantkoenig but maybe you forgot to replace CreateHookTask to createHookTask?

return prepareWebhook(x, w, repo, event, p)
}

func prepareWebhook(e Engine, w *Webhook, repo *Repository, event HookEventType, p api.Payloader) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing HookEventRepository on switch case. And missing handle on GetSlackPayload and GetDiscordPayload.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added missing case to HookEventRepository. Will hopefully get change to add handles to GetSlackPayload and GetDiscordPayload tomorrow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunny Done

@lunny lunny added type/feature Completely new functionality. Can only be merged if feature freeze is not active. and removed modifies/api This PR adds API routes or modifies them labels Aug 30, 2017
@lunny
Copy link
Member

lunny commented Sep 3, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 3, 2017
@lafriks
Copy link
Member

lafriks commented Sep 3, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 3, 2017
@lafriks lafriks merged commit b689bb6 into go-gitea:master Sep 3, 2017
@stephenc
Copy link

stephenc commented Sep 3, 2017

(party) - when can we expect a release?

@lunny
Copy link
Member

lunny commented Sep 3, 2017

This is a part of v1.3 should be released 2017.10.25

@lunny
Copy link
Member

lunny commented Sep 3, 2017

@ethantkoenig maybe add rename webhook

@lunny
Copy link
Member

lunny commented Sep 3, 2017

And the option should be only when an orgnization webhook, when create/edit a repository webhoo, it should be hidden.

Repository
Repository created or deleted

@ethantkoenig ethantkoenig deleted the etk/org_webhook branch September 9, 2017 23:40
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants