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

Issue #170: Added field mapping for repository edited, renamed and transfer event. #171

Merged
merged 1 commit into from
May 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ func TestWebhooks(t *testing.T) {
"X-Hub-Signature": []string{"sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e"},
},
},
{
name: "RepositoryEditedEvent",
event: RepositoryEvent,
typ: RepositoryPayload{},
filename: "../testdata/github/repository-edited.json",
headers: http.Header{
"X-Github-Event": []string{"repository"},
"X-Hub-Signature": []string{"sha1=4edb36f8c0a8e3905e340c7af4b3af9a21d93acc"},
},
},
{
name: "RepositoryVulnerabilityAlertEvent",
event: RepositoryVulnerabilityAlertEvent,
Expand Down
24 changes: 23 additions & 1 deletion github/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -5431,7 +5431,29 @@ type ReleasePayload struct {

// RepositoryPayload contains the information for GitHub's repository hook event
type RepositoryPayload struct {
Action string `json:"action"`
Action string `json:"action"`
Changes struct {
DefaultBranch struct {
From string `json:"from"`
} `json:"default_branch,omitempty"`
Description struct {
From string `json:"from"`
} `json:"description,omitempty"`
Homepage struct {
From string `json:"from"`
} `json:"homepage,omitempty"`
Topics struct {
From string `json:"from,omitempty"`
} `json:"topics,omitempty"`
Repository struct {
Name struct {
From string `json:"from"`
} `json:"name"`
} `json:"repository,omitempty"`
Owner struct {
From string `json:"from"`
} `json:"owner,omitempty"`
} `json:"changes,omitempty"`
Repository struct {
ID int64 `json:"id"`
NodeID string `json:"node_id"`
Expand Down
124 changes: 124 additions & 0 deletions testdata/github/repository-edited.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"action": "created",
"changes": {
"default_branch": {
"from": "master"
}
},
"repository": {
"id": 27496774,
"name": "new-repository",
"full_name": "baxterandthehackers/new-repository",
"owner": {
"login": "baxterandthehackers",
"id": 7649605,
"avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/baxterandthehackers",
"html_url": "https://github.com/baxterandthehackers",
"followers_url": "https://api.github.com/users/baxterandthehackers/followers",
"following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}",
"gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}",
"starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions",
"organizations_url": "https://api.github.com/users/baxterandthehackers/orgs",
"repos_url": "https://api.github.com/users/baxterandthehackers/repos",
"events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}",
"received_events_url": "https://api.github.com/users/baxterandthehackers/received_events",
"type": "Organization",
"site_admin": false
},
"private": true,
"html_url": "https://github.com/baxterandthehackers/new-repository",
"description": "",
"fork": false,
"url": "https://api.github.com/repos/baxterandthehackers/new-repository",
"forks_url": "https://api.github.com/repos/baxterandthehackers/new-repository/forks",
"keys_url": "https://api.github.com/repos/baxterandthehackers/new-repository/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/baxterandthehackers/new-repository/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/baxterandthehackers/new-repository/teams",
"hooks_url": "https://api.github.com/repos/baxterandthehackers/new-repository/hooks",
"issue_events_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues/events{/number}",
"events_url": "https://api.github.com/repos/baxterandthehackers/new-repository/events",
"assignees_url": "https://api.github.com/repos/baxterandthehackers/new-repository/assignees{/user}",
"branches_url": "https://api.github.com/repos/baxterandthehackers/new-repository/branches{/branch}",
"tags_url": "https://api.github.com/repos/baxterandthehackers/new-repository/tags",
"blobs_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/baxterandthehackers/new-repository/statuses/{sha}",
"languages_url": "https://api.github.com/repos/baxterandthehackers/new-repository/languages",
"stargazers_url": "https://api.github.com/repos/baxterandthehackers/new-repository/stargazers",
"contributors_url": "https://api.github.com/repos/baxterandthehackers/new-repository/contributors",
"subscribers_url": "https://api.github.com/repos/baxterandthehackers/new-repository/subscribers",
"subscription_url": "https://api.github.com/repos/baxterandthehackers/new-repository/subscription",
"commits_url": "https://api.github.com/repos/baxterandthehackers/new-repository/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/baxterandthehackers/new-repository/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues/comments/{number}",
"contents_url": "https://api.github.com/repos/baxterandthehackers/new-repository/contents/{+path}",
"compare_url": "https://api.github.com/repos/baxterandthehackers/new-repository/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/baxterandthehackers/new-repository/merges",
"archive_url": "https://api.github.com/repos/baxterandthehackers/new-repository/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/baxterandthehackers/new-repository/downloads",
"issues_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues{/number}",
"pulls_url": "https://api.github.com/repos/baxterandthehackers/new-repository/pulls{/number}",
"milestones_url": "https://api.github.com/repos/baxterandthehackers/new-repository/milestones{/number}",
"notifications_url": "https://api.github.com/repos/baxterandthehackers/new-repository/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/baxterandthehackers/new-repository/labels{/name}",
"releases_url": "https://api.github.com/repos/baxterandthehackers/new-repository/releases{/id}",
"created_at": "2014-12-03T16:39:25Z",
"updated_at": "2014-12-03T16:39:25Z",
"pushed_at": "2014-12-03T16:39:25Z",
"git_url": "git://github.com/baxterandthehackers/new-repository.git",
"ssh_url": "[email protected]:baxterandthehackers/new-repository.git",
"clone_url": "https://github.com/baxterandthehackers/new-repository.git",
"svn_url": "https://github.com/baxterandthehackers/new-repository",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main"
},
"organization": {
"login": "baxterandthehackers",
"id": 7649605,
"url": "https://api.github.com/orgs/baxterandthehackers",
"repos_url": "https://api.github.com/orgs/baxterandthehackers/repos",
"events_url": "https://api.github.com/orgs/baxterandthehackers/events",
"members_url": "https://api.github.com/orgs/baxterandthehackers/members{/member}",
"public_members_url": "https://api.github.com/orgs/baxterandthehackers/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=2"
},
"sender": {
"login": "baxterthehacker",
"id": 6752317,
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=2",
"gravatar_id": "",
"url": "https://api.github.com/users/baxterthehacker",
"html_url": "https://github.com/baxterthehacker",
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
"type": "User",
"site_admin": false
}
}