Skip to content

Commit c330e11

Browse files
author
Dean Karn
authored
Merge pull request #171 from iamsumit/issue-170
Issue #170: Added field mapping for repository edited, renamed and transfer event.
2 parents 75f0d82 + 4c57cb2 commit c330e11

File tree

3 files changed

+157
-1
lines changed

3 files changed

+157
-1
lines changed

github/github_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,16 @@ func TestWebhooks(t *testing.T) {
483483
"X-Hub-Signature": []string{"sha1=df442a8af41edd2d42ccdd997938d1d111b0f94e"},
484484
},
485485
},
486+
{
487+
name: "RepositoryEditedEvent",
488+
event: RepositoryEvent,
489+
typ: RepositoryPayload{},
490+
filename: "../testdata/github/repository-edited.json",
491+
headers: http.Header{
492+
"X-Github-Event": []string{"repository"},
493+
"X-Hub-Signature": []string{"sha1=4edb36f8c0a8e3905e340c7af4b3af9a21d93acc"},
494+
},
495+
},
486496
{
487497
name: "RepositoryVulnerabilityAlertEvent",
488498
event: RepositoryVulnerabilityAlertEvent,

github/payload.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5431,7 +5431,29 @@ type ReleasePayload struct {
54315431

54325432
// RepositoryPayload contains the information for GitHub's repository hook event
54335433
type RepositoryPayload struct {
5434-
Action string `json:"action"`
5434+
Action string `json:"action"`
5435+
Changes struct {
5436+
DefaultBranch struct {
5437+
From string `json:"from"`
5438+
} `json:"default_branch,omitempty"`
5439+
Description struct {
5440+
From string `json:"from"`
5441+
} `json:"description,omitempty"`
5442+
Homepage struct {
5443+
From string `json:"from"`
5444+
} `json:"homepage,omitempty"`
5445+
Topics struct {
5446+
From string `json:"from,omitempty"`
5447+
} `json:"topics,omitempty"`
5448+
Repository struct {
5449+
Name struct {
5450+
From string `json:"from"`
5451+
} `json:"name"`
5452+
} `json:"repository,omitempty"`
5453+
Owner struct {
5454+
From string `json:"from"`
5455+
} `json:"owner,omitempty"`
5456+
} `json:"changes,omitempty"`
54355457
Repository struct {
54365458
ID int64 `json:"id"`
54375459
NodeID string `json:"node_id"`
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"action": "created",
3+
"changes": {
4+
"default_branch": {
5+
"from": "master"
6+
}
7+
},
8+
"repository": {
9+
"id": 27496774,
10+
"name": "new-repository",
11+
"full_name": "baxterandthehackers/new-repository",
12+
"owner": {
13+
"login": "baxterandthehackers",
14+
"id": 7649605,
15+
"avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3",
16+
"gravatar_id": "",
17+
"url": "https://api.github.com/users/baxterandthehackers",
18+
"html_url": "https://github.com/baxterandthehackers",
19+
"followers_url": "https://api.github.com/users/baxterandthehackers/followers",
20+
"following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}",
21+
"gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}",
22+
"starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}",
23+
"subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions",
24+
"organizations_url": "https://api.github.com/users/baxterandthehackers/orgs",
25+
"repos_url": "https://api.github.com/users/baxterandthehackers/repos",
26+
"events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}",
27+
"received_events_url": "https://api.github.com/users/baxterandthehackers/received_events",
28+
"type": "Organization",
29+
"site_admin": false
30+
},
31+
"private": true,
32+
"html_url": "https://github.com/baxterandthehackers/new-repository",
33+
"description": "",
34+
"fork": false,
35+
"url": "https://api.github.com/repos/baxterandthehackers/new-repository",
36+
"forks_url": "https://api.github.com/repos/baxterandthehackers/new-repository/forks",
37+
"keys_url": "https://api.github.com/repos/baxterandthehackers/new-repository/keys{/key_id}",
38+
"collaborators_url": "https://api.github.com/repos/baxterandthehackers/new-repository/collaborators{/collaborator}",
39+
"teams_url": "https://api.github.com/repos/baxterandthehackers/new-repository/teams",
40+
"hooks_url": "https://api.github.com/repos/baxterandthehackers/new-repository/hooks",
41+
"issue_events_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues/events{/number}",
42+
"events_url": "https://api.github.com/repos/baxterandthehackers/new-repository/events",
43+
"assignees_url": "https://api.github.com/repos/baxterandthehackers/new-repository/assignees{/user}",
44+
"branches_url": "https://api.github.com/repos/baxterandthehackers/new-repository/branches{/branch}",
45+
"tags_url": "https://api.github.com/repos/baxterandthehackers/new-repository/tags",
46+
"blobs_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/blobs{/sha}",
47+
"git_tags_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/tags{/sha}",
48+
"git_refs_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/refs{/sha}",
49+
"trees_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/trees{/sha}",
50+
"statuses_url": "https://api.github.com/repos/baxterandthehackers/new-repository/statuses/{sha}",
51+
"languages_url": "https://api.github.com/repos/baxterandthehackers/new-repository/languages",
52+
"stargazers_url": "https://api.github.com/repos/baxterandthehackers/new-repository/stargazers",
53+
"contributors_url": "https://api.github.com/repos/baxterandthehackers/new-repository/contributors",
54+
"subscribers_url": "https://api.github.com/repos/baxterandthehackers/new-repository/subscribers",
55+
"subscription_url": "https://api.github.com/repos/baxterandthehackers/new-repository/subscription",
56+
"commits_url": "https://api.github.com/repos/baxterandthehackers/new-repository/commits{/sha}",
57+
"git_commits_url": "https://api.github.com/repos/baxterandthehackers/new-repository/git/commits{/sha}",
58+
"comments_url": "https://api.github.com/repos/baxterandthehackers/new-repository/comments{/number}",
59+
"issue_comment_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues/comments/{number}",
60+
"contents_url": "https://api.github.com/repos/baxterandthehackers/new-repository/contents/{+path}",
61+
"compare_url": "https://api.github.com/repos/baxterandthehackers/new-repository/compare/{base}...{head}",
62+
"merges_url": "https://api.github.com/repos/baxterandthehackers/new-repository/merges",
63+
"archive_url": "https://api.github.com/repos/baxterandthehackers/new-repository/{archive_format}{/ref}",
64+
"downloads_url": "https://api.github.com/repos/baxterandthehackers/new-repository/downloads",
65+
"issues_url": "https://api.github.com/repos/baxterandthehackers/new-repository/issues{/number}",
66+
"pulls_url": "https://api.github.com/repos/baxterandthehackers/new-repository/pulls{/number}",
67+
"milestones_url": "https://api.github.com/repos/baxterandthehackers/new-repository/milestones{/number}",
68+
"notifications_url": "https://api.github.com/repos/baxterandthehackers/new-repository/notifications{?since,all,participating}",
69+
"labels_url": "https://api.github.com/repos/baxterandthehackers/new-repository/labels{/name}",
70+
"releases_url": "https://api.github.com/repos/baxterandthehackers/new-repository/releases{/id}",
71+
"created_at": "2014-12-03T16:39:25Z",
72+
"updated_at": "2014-12-03T16:39:25Z",
73+
"pushed_at": "2014-12-03T16:39:25Z",
74+
"git_url": "git://github.com/baxterandthehackers/new-repository.git",
75+
"ssh_url": "[email protected]:baxterandthehackers/new-repository.git",
76+
"clone_url": "https://github.com/baxterandthehackers/new-repository.git",
77+
"svn_url": "https://github.com/baxterandthehackers/new-repository",
78+
"homepage": null,
79+
"size": 0,
80+
"stargazers_count": 0,
81+
"watchers_count": 0,
82+
"language": null,
83+
"has_issues": true,
84+
"has_downloads": true,
85+
"has_wiki": true,
86+
"has_pages": false,
87+
"forks_count": 0,
88+
"mirror_url": null,
89+
"open_issues_count": 0,
90+
"forks": 0,
91+
"open_issues": 0,
92+
"watchers": 0,
93+
"default_branch": "main"
94+
},
95+
"organization": {
96+
"login": "baxterandthehackers",
97+
"id": 7649605,
98+
"url": "https://api.github.com/orgs/baxterandthehackers",
99+
"repos_url": "https://api.github.com/orgs/baxterandthehackers/repos",
100+
"events_url": "https://api.github.com/orgs/baxterandthehackers/events",
101+
"members_url": "https://api.github.com/orgs/baxterandthehackers/members{/member}",
102+
"public_members_url": "https://api.github.com/orgs/baxterandthehackers/public_members{/member}",
103+
"avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=2"
104+
},
105+
"sender": {
106+
"login": "baxterthehacker",
107+
"id": 6752317,
108+
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=2",
109+
"gravatar_id": "",
110+
"url": "https://api.github.com/users/baxterthehacker",
111+
"html_url": "https://github.com/baxterthehacker",
112+
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
113+
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
114+
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
115+
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
116+
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
117+
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
118+
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
119+
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
120+
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
121+
"type": "User",
122+
"site_admin": false
123+
}
124+
}

0 commit comments

Comments
 (0)