-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathevent.go
More file actions
67 lines (55 loc) · 1.89 KB
/
Copy pathevent.go
File metadata and controls
67 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import "github.com/google/go-github/v50/github"
// LabelEvent is an interface that represents a GitHub event that can be used for labeling.
type LabelEvent interface {
// The name of the repository
RepoName() string
// The owner of the repository
RepoOwner() string
// The number of the pull request
PRNumber() int
// Current labels on the pull request
PRLabels() []*github.Label
}
// PullRequestEvent represents a GitHub Pull Request event.
// It implements the LabelEvent interface.
type PullRequestEvent struct {
event github.PullRequestEvent
}
// PRLabels returns the labels on the pull request.
func (e PullRequestEvent) PRLabels() []*github.Label {
return e.event.PullRequest.Labels
}
// PRNumber returns the number of the pull request.
func (e PullRequestEvent) PRNumber() int {
return *e.event.PullRequest.Number
}
// RepoName returns the name of the repository.
func (e PullRequestEvent) RepoName() string {
return *e.event.PullRequest.Base.Repo.Name
}
// RepoOwner returns the owner of the repository.
func (e PullRequestEvent) RepoOwner() string {
return *e.event.PullRequest.Base.Repo.Owner.Login
}
// PullRequestTargetEvent represents a GitHub Pull Request Target event.
// It implements the LabelEvent interface.
type PullRequestTargetEvent struct {
event github.PullRequestTargetEvent
}
// PRLabels returns the labels on the pull request.
func (e PullRequestTargetEvent) PRLabels() []*github.Label {
return e.event.PullRequest.Labels
}
// PRNumber returns the number of the pull request.
func (e PullRequestTargetEvent) PRNumber() int {
return *e.event.PullRequest.Number
}
// RepoName returns the name of the repository.
func (e PullRequestTargetEvent) RepoName() string {
return *e.event.PullRequest.Base.Repo.Name
}
// RepoOwner returns the owner of the repository.
func (e PullRequestTargetEvent) RepoOwner() string {
return *e.event.PullRequest.Base.Repo.Owner.Login
}