Skip to content

Commit

Permalink
Add Organization to PushEvent and IssueCommentEvent (#2116)
Browse files Browse the repository at this point in the history
Fixes: #2115.
  • Loading branch information
lluiscampos authored Oct 5, 2021
1 parent 3ad22bc commit c67c0c3
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 1 deletion.
8 changes: 8 additions & 0 deletions github/event_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ type IssueCommentEvent struct {
Repo *Repository `json:"repository,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`

// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Organization *Organization `json:"organization,omitempty"`
}

// IssuesEvent is triggered when an issue is opened, edited, deleted, transferred,
Expand Down Expand Up @@ -819,6 +823,10 @@ type PushEvent struct {
Pusher *User `json:"pusher,omitempty"`
Sender *User `json:"sender,omitempty"`
Installation *Installation `json:"installation,omitempty"`

// The following field is only present when the webhook is triggered on
// a repository belonging to an organization.
Organization *Organization `json:"organization,omitempty"`
}

func (p PushEvent) String() string {
Expand Down
88 changes: 88 additions & 0 deletions github/event_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,28 @@ func TestIssueCommentEvent_Marshal(t *testing.T) {
},
SuspendedAt: &Timestamp{referenceTime},
},
Organization: &Organization{
BillingEmail: String("be"),
Blog: String("b"),
Company: String("c"),
Email: String("e"),
TwitterUsername: String("tu"),
Location: String("loc"),
Name: String("n"),
Description: String("d"),
IsVerified: Bool(true),
HasOrganizationProjects: Bool(true),
HasRepositoryProjects: Bool(true),
DefaultRepoPermission: String("drp"),
MembersCanCreateRepos: Bool(true),
MembersCanCreateInternalRepos: Bool(true),
MembersCanCreatePrivateRepos: Bool(true),
MembersCanCreatePublicRepos: Bool(false),
MembersAllowedRepositoryCreationType: String("marct"),
MembersCanCreatePages: Bool(true),
MembersCanCreatePublicPages: Bool(false),
MembersCanCreatePrivatePages: Bool(true),
},
}

want := `{
Expand Down Expand Up @@ -1862,6 +1884,28 @@ func TestIssueCommentEvent_Marshal(t *testing.T) {
"url": "u"
},
"suspended_at": ` + referenceTimeStr + `
},
"organization": {
"name": "n",
"company": "c",
"blog": "b",
"location": "loc",
"email": "e",
"twitter_username": "tu",
"description": "d",
"billing_email": "be",
"is_verified": true,
"has_organization_projects": true,
"has_repository_projects": true,
"default_repository_permission": "drp",
"members_can_create_repositories": true,
"members_can_create_public_repositories": false,
"members_can_create_private_repositories": true,
"members_can_create_internal_repositories": true,
"members_allowed_repository_creation_type": "marct",
"members_can_create_pages": true,
"members_can_create_public_pages": false,
"members_can_create_private_pages": true
}
}`

Expand Down Expand Up @@ -3410,6 +3454,28 @@ func TestPushEvent_Marshal(t *testing.T) {
},
SuspendedAt: &Timestamp{referenceTime},
},
Organization: &Organization{
BillingEmail: String("be"),
Blog: String("b"),
Company: String("c"),
Email: String("e"),
TwitterUsername: String("tu"),
Location: String("loc"),
Name: String("n"),
Description: String("d"),
IsVerified: Bool(true),
HasOrganizationProjects: Bool(true),
HasRepositoryProjects: Bool(true),
DefaultRepoPermission: String("drp"),
MembersCanCreateRepos: Bool(true),
MembersCanCreateInternalRepos: Bool(true),
MembersCanCreatePrivateRepos: Bool(true),
MembersCanCreatePublicRepos: Bool(false),
MembersAllowedRepositoryCreationType: String("marct"),
MembersCanCreatePages: Bool(true),
MembersCanCreatePublicPages: Bool(false),
MembersCanCreatePrivatePages: Bool(true),
},
}

want := `{
Expand Down Expand Up @@ -3550,6 +3616,28 @@ func TestPushEvent_Marshal(t *testing.T) {
"url": "u"
},
"suspended_at": ` + referenceTimeStr + `
},
"organization": {
"name": "n",
"company": "c",
"blog": "b",
"location": "loc",
"email": "e",
"twitter_username": "tu",
"description": "d",
"billing_email": "be",
"is_verified": true,
"has_organization_projects": true,
"has_repository_projects": true,
"default_repository_permission": "drp",
"members_can_create_repositories": true,
"members_can_create_public_repositories": false,
"members_can_create_private_repositories": true,
"members_can_create_internal_repositories": true,
"members_allowed_repository_creation_type": "marct",
"members_can_create_pages": true,
"members_can_create_public_pages": false,
"members_can_create_private_pages": true
}
}`

Expand Down
16 changes: 16 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion github/github-stringify_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c67c0c3

Please sign in to comment.