Skip to content

Commit

Permalink
feat(github): support fork event
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 31, 2020
1 parent 64e5dcf commit feb6698
Show file tree
Hide file tree
Showing 3 changed files with 244 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/plugin-github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,8 @@ export function apply(ctx: Context, config: Config = {}) {
...commits.map(c => `[${c.id.slice(0, 6)}] ${formatMarkdown(c.message)}`),
].join('\n')]
})

registerHandler('fork', ({ repository, sender, forkee }) => {
return [`[GitHub] ${sender.login} forked ${repository.full_name} to ${forkee.full_name}`]
})
}
237 changes: 237 additions & 0 deletions packages/plugin-github/tests/fixtures/fork.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"forkee": {
"id": 290096040,
"node_id": "MDEwOlJlcG9zaXRvcnkyOTAwOTYwNDA=",
"name": "koishi",
"full_name": "jjyyxx/koishi",
"private": false,
"owner": {
"login": "jjyyxx",
"id": 13808089,
"node_id": "MDQ6VXNlcjEzODA4MDg5",
"avatar_url": "https://avatars3.githubusercontent.com/u/13808089?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jjyyxx",
"html_url": "https://github.com/jjyyxx",
"followers_url": "https://api.github.com/users/jjyyxx/followers",
"following_url": "https://api.github.com/users/jjyyxx/following{/other_user}",
"gists_url": "https://api.github.com/users/jjyyxx/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jjyyxx/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jjyyxx/subscriptions",
"organizations_url": "https://api.github.com/users/jjyyxx/orgs",
"repos_url": "https://api.github.com/users/jjyyxx/repos",
"events_url": "https://api.github.com/users/jjyyxx/events{/privacy}",
"received_events_url": "https://api.github.com/users/jjyyxx/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/jjyyxx/koishi",
"description": "QQ bot out of the box",
"fork": true,
"url": "https://api.github.com/repos/jjyyxx/koishi",
"forks_url": "https://api.github.com/repos/jjyyxx/koishi/forks",
"keys_url": "https://api.github.com/repos/jjyyxx/koishi/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/jjyyxx/koishi/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/jjyyxx/koishi/teams",
"hooks_url": "https://api.github.com/repos/jjyyxx/koishi/hooks",
"issue_events_url": "https://api.github.com/repos/jjyyxx/koishi/issues/events{/number}",
"events_url": "https://api.github.com/repos/jjyyxx/koishi/events",
"assignees_url": "https://api.github.com/repos/jjyyxx/koishi/assignees{/user}",
"branches_url": "https://api.github.com/repos/jjyyxx/koishi/branches{/branch}",
"tags_url": "https://api.github.com/repos/jjyyxx/koishi/tags",
"blobs_url": "https://api.github.com/repos/jjyyxx/koishi/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/jjyyxx/koishi/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/jjyyxx/koishi/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/jjyyxx/koishi/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/jjyyxx/koishi/statuses/{sha}",
"languages_url": "https://api.github.com/repos/jjyyxx/koishi/languages",
"stargazers_url": "https://api.github.com/repos/jjyyxx/koishi/stargazers",
"contributors_url": "https://api.github.com/repos/jjyyxx/koishi/contributors",
"subscribers_url": "https://api.github.com/repos/jjyyxx/koishi/subscribers",
"subscription_url": "https://api.github.com/repos/jjyyxx/koishi/subscription",
"commits_url": "https://api.github.com/repos/jjyyxx/koishi/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/jjyyxx/koishi/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/jjyyxx/koishi/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/jjyyxx/koishi/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/jjyyxx/koishi/contents/{+path}",
"compare_url": "https://api.github.com/repos/jjyyxx/koishi/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/jjyyxx/koishi/merges",
"archive_url": "https://api.github.com/repos/jjyyxx/koishi/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/jjyyxx/koishi/downloads",
"issues_url": "https://api.github.com/repos/jjyyxx/koishi/issues{/number}",
"pulls_url": "https://api.github.com/repos/jjyyxx/koishi/pulls{/number}",
"milestones_url": "https://api.github.com/repos/jjyyxx/koishi/milestones{/number}",
"notifications_url": "https://api.github.com/repos/jjyyxx/koishi/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/jjyyxx/koishi/labels{/name}",
"releases_url": "https://api.github.com/repos/jjyyxx/koishi/releases{/id}",
"deployments_url": "https://api.github.com/repos/jjyyxx/koishi/deployments",
"created_at": "2020-08-25T02:51:14Z",
"updated_at": "2020-08-24T19:15:52Z",
"pushed_at": "2020-08-24T18:51:18Z",
"git_url": "git://github.com/jjyyxx/koishi.git",
"ssh_url": "git@github.com:jjyyxx/koishi.git",
"clone_url": "https://github.com/jjyyxx/koishi.git",
"svn_url": "https://github.com/jjyyxx/koishi",
"homepage": "https://koishi.js.org",
"size": 2438,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": false,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 0,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master",
"public": true
},
"repository": {
"id": 225572038,
"node_id": "MDEwOlJlcG9zaXRvcnkyMjU1NzIwMzg=",
"name": "koishi",
"full_name": "koishijs/koishi",
"private": false,
"owner": {
"login": "koishijs",
"id": 58179220,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU4MTc5MjIw",
"avatar_url": "https://avatars3.githubusercontent.com/u/58179220?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/koishijs",
"html_url": "https://github.com/koishijs",
"followers_url": "https://api.github.com/users/koishijs/followers",
"following_url": "https://api.github.com/users/koishijs/following{/other_user}",
"gists_url": "https://api.github.com/users/koishijs/gists{/gist_id}",
"starred_url": "https://api.github.com/users/koishijs/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/koishijs/subscriptions",
"organizations_url": "https://api.github.com/users/koishijs/orgs",
"repos_url": "https://api.github.com/users/koishijs/repos",
"events_url": "https://api.github.com/users/koishijs/events{/privacy}",
"received_events_url": "https://api.github.com/users/koishijs/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/koishijs/koishi",
"description": "QQ bot out of the box",
"fork": false,
"url": "https://api.github.com/repos/koishijs/koishi",
"forks_url": "https://api.github.com/repos/koishijs/koishi/forks",
"keys_url": "https://api.github.com/repos/koishijs/koishi/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/koishijs/koishi/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/koishijs/koishi/teams",
"hooks_url": "https://api.github.com/repos/koishijs/koishi/hooks",
"issue_events_url": "https://api.github.com/repos/koishijs/koishi/issues/events{/number}",
"events_url": "https://api.github.com/repos/koishijs/koishi/events",
"assignees_url": "https://api.github.com/repos/koishijs/koishi/assignees{/user}",
"branches_url": "https://api.github.com/repos/koishijs/koishi/branches{/branch}",
"tags_url": "https://api.github.com/repos/koishijs/koishi/tags",
"blobs_url": "https://api.github.com/repos/koishijs/koishi/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/koishijs/koishi/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/koishijs/koishi/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/koishijs/koishi/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/koishijs/koishi/statuses/{sha}",
"languages_url": "https://api.github.com/repos/koishijs/koishi/languages",
"stargazers_url": "https://api.github.com/repos/koishijs/koishi/stargazers",
"contributors_url": "https://api.github.com/repos/koishijs/koishi/contributors",
"subscribers_url": "https://api.github.com/repos/koishijs/koishi/subscribers",
"subscription_url": "https://api.github.com/repos/koishijs/koishi/subscription",
"commits_url": "https://api.github.com/repos/koishijs/koishi/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/koishijs/koishi/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/koishijs/koishi/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/koishijs/koishi/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/koishijs/koishi/contents/{+path}",
"compare_url": "https://api.github.com/repos/koishijs/koishi/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/koishijs/koishi/merges",
"archive_url": "https://api.github.com/repos/koishijs/koishi/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/koishijs/koishi/downloads",
"issues_url": "https://api.github.com/repos/koishijs/koishi/issues{/number}",
"pulls_url": "https://api.github.com/repos/koishijs/koishi/pulls{/number}",
"milestones_url": "https://api.github.com/repos/koishijs/koishi/milestones{/number}",
"notifications_url": "https://api.github.com/repos/koishijs/koishi/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/koishijs/koishi/labels{/name}",
"releases_url": "https://api.github.com/repos/koishijs/koishi/releases{/id}",
"deployments_url": "https://api.github.com/repos/koishijs/koishi/deployments",
"created_at": "2019-12-03T08:47:29Z",
"updated_at": "2020-08-24T19:15:52Z",
"pushed_at": "2020-08-24T18:51:18Z",
"git_url": "git://github.com/koishijs/koishi.git",
"ssh_url": "git@github.com:koishijs/koishi.git",
"clone_url": "https://github.com/koishijs/koishi.git",
"svn_url": "https://github.com/koishijs/koishi",
"homepage": "https://koishi.js.org",
"size": 2438,
"stargazers_count": 186,
"watchers_count": 186,
"language": "TypeScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"forks_count": 12,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 2,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"forks": 12,
"open_issues": 2,
"watchers": 186,
"default_branch": "master"
},
"organization": {
"login": "koishijs",
"id": 58179220,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU4MTc5MjIw",
"url": "https://api.github.com/orgs/koishijs",
"repos_url": "https://api.github.com/orgs/koishijs/repos",
"events_url": "https://api.github.com/orgs/koishijs/events",
"hooks_url": "https://api.github.com/orgs/koishijs/hooks",
"issues_url": "https://api.github.com/orgs/koishijs/issues",
"members_url": "https://api.github.com/orgs/koishijs/members{/member}",
"public_members_url": "https://api.github.com/orgs/koishijs/public_members{/member}",
"avatar_url": "https://avatars3.githubusercontent.com/u/58179220?v=4",
"description": ""
},
"sender": {
"login": "jjyyxx",
"id": 13808089,
"node_id": "MDQ6VXNlcjEzODA4MDg5",
"avatar_url": "https://avatars3.githubusercontent.com/u/13808089?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jjyyxx",
"html_url": "https://github.com/jjyyxx",
"followers_url": "https://api.github.com/users/jjyyxx/followers",
"following_url": "https://api.github.com/users/jjyyxx/following{/other_user}",
"gists_url": "https://api.github.com/users/jjyyxx/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jjyyxx/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jjyyxx/subscriptions",
"organizations_url": "https://api.github.com/users/jjyyxx/orgs",
"repos_url": "https://api.github.com/users/jjyyxx/repos",
"events_url": "https://api.github.com/users/jjyyxx/events{/privacy}",
"received_events_url": "https://api.github.com/users/jjyyxx/received_events",
"type": "User",
"site_admin": false
}
}
3 changes: 3 additions & 0 deletions packages/plugin-github/tests/index.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module.exports[`commit_comment.created`] = `
URL: https://github.com/koishijs/koishi/commit/bff469eabe14d42683a4f7c3ccb659daec5e1c00#commitcomment-36878220
This will introduce a failure in test.`

module.exports[`fork`] = `
[GitHub] jjyyxx forked koishijs/koishi to jjyyxx/koishi`

module.exports[`issue_comment.created.1`] = `
[GitHub] simon300000 commented on issue koishijs/koishi#19
URL: https://github.com/koishijs/koishi/issues/19#issuecomment-576277946
Expand Down

0 comments on commit feb6698

Please sign in to comment.