Skip to content

Commit

Permalink
Support for repo creation/deletion webhooks (gogs#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethantkoenig authored and appleboy committed May 4, 2017
1 parent e1c76d4 commit a391123
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions gitea/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,39 @@ func (p *PullRequestPayload) SetSecret(secret string) {
func (p *PullRequestPayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}

//__________ .__ __
//\______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ |
// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____|
// \/ \/|__| \/ \/

// HookRepoAction an action that happens to a repo
type HookRepoAction string

const (
// HookRepoCreated created
HookRepoCreated HookRepoAction = "created"
// HookRepoDeleted deleted
HookRepoDeleted HookRepoAction = "deleted"
)

// RepositoryPayload payload for repository webhooks
type RepositoryPayload struct {
Secret string `json:"secret"`
Action HookRepoAction `json:"action"`
Repository *Repository `json:"repository"`
Organization *User `json:"organization"`
Sender *User `json:"sender"`
}

// SetSecret set the payload's secret
func (p *RepositoryPayload) SetSecret(secret string) {
p.Secret = secret
}

// JSONPayload JSON representation of the payload
func (p *RepositoryPayload) JSONPayload() ([]byte, error) {
return json.MarshalIndent(p, "", " ")
}

0 comments on commit a391123

Please sign in to comment.