Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Issue webhook payload #38

Merged
merged 11 commits into from
Feb 13, 2017
Merged

Issue webhook payload #38

merged 11 commits into from
Feb 13, 2017

Conversation

thehowl
Copy link

@thehowl thehowl commented Feb 11, 2017

This PR prepares for an upcoming pull request on the main repository that aims to implement go-gitea/gitea#132, adding webhook for issue events.

A small API breakage would be introduced in the SDK (though the API JSON objects' structure would remain untouched, if not for some shifting of the position of the fields). As most fields between the PullRequestPayload and the IssuePayload would be the same, the idea is to move the fields to a common BaseIssuePayload, although this would bring a small breakage to when constructing the struct of a PullRequestPayload:

// No longer possible after this PR
pr := &gitea.PullRequestPayload{
	Index: 64, 
}

However, accessing the struct fields would still be possible after the struct is initialised.

pr := &gitea.PullRequestPayload{}
pr.Index = 64
_ = pr.Index

This would be, however, a very small issue, as the PullRequestPayload is only initialised by Gitea itself (see this github search), but Gitea vendors its dependencies anyway, so this would break only in the event of a vendor update with no update to models/issue.go's struct initialisations.

gitea/hook.go Outdated
@@ -2,6 +2,10 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

// Copyright 2017 The Gitea Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

This line is the only need and put it after the first line.

@lunny
Copy link
Member

lunny commented Feb 11, 2017

How about use the duplicated struct between Issue and Pull for the compitable?

@thehowl
Copy link
Author

thehowl commented Feb 11, 2017

For the computable? I'm sorry, I did not understand. Could you elaborate?

gitea/hook.go Outdated
Issue *Issue `json:"issue"`
}

// JSONPayload FIXME
Copy link
Member

Choose a reason for hiding this comment

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

comment

@lunny
Copy link
Member

lunny commented Feb 11, 2017

I mean maybe remove BaseIssuePayload and copy the fields to IssuePayload and PullPayload is better.

@thehowl
Copy link
Author

thehowl commented Feb 11, 2017

Yeah, that was how I originally thought about doing it (and the safest way, since it doesn't cause any breakage). However, it's a matter of convenience and code de-duplication.

I'm gonna do as you said anyway, mostly because of what @tboerger said on Gitter.

@lunny
Copy link
Member

lunny commented Feb 11, 2017

LGTM

Since the Gitea webhooks currently mimic for a big part the way GitHub does webhook, issue comments HookIssueActions have been removed to be added again at a later stage and milestone_set and milestone_cleared have been changed to milestoned and demilestoned, respectively.
@thehowl
Copy link
Author

thehowl commented Feb 11, 2017

I've changed the HookIssueAction names of the ones I added, and removed the comment ones, to better mimic the GitHub webhooks. Issue comments will come at a later stage (and PR).

@tboerger
Copy link
Member

LGTM

@lunny lunny merged commit 87b8065 into go-gitea:master Feb 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants