integrations: Add missing event handling to Gogs.

Issues event where not handled by Gogs integrations.
This added them to supported events.
This commit is contained in:
Jan Koscisz 2019-11-18 03:41:13 +01:00 committed by Tim Abbott
parent 4e421ebe12
commit ace1503cb6
13 changed files with 1170 additions and 2 deletions

View File

@ -0,0 +1,91 @@
{
"action": "edited",
"issue": {
"id": 5267,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Test",
"labels": [],
"milestone": null,
"assignee": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"state": "open",
"comments": 2,
"created_at": "2019-11-17T20:50:48Z",
"updated_at": "2019-11-17T23:01:06Z",
"pull_request": null
},
"comment": {
"id": 3634,
"html_url": "https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3634",
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"body": "edit comment",
"created_at": "2019-11-17T20:51:01Z",
"updated_at": "2019-11-17T20:51:01Z"
},
"changes": {
"body": {
"from": "comment"
}
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 49152,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-17T23:18:17Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,79 @@
{
"action": "created",
"issue": {
"id": 5267,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Closing",
"labels": [],
"milestone": null,
"assignee": null,
"state": "open",
"comments": 1,
"created_at": "2019-11-17T20:50:48Z",
"updated_at": "2019-11-17T20:51:01Z",
"pull_request": null
},
"comment": {
"id": 3635,
"html_url": "https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3635",
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"body": "Test comment",
"created_at": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z"
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 1,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,72 @@
{
"action": "assigned",
"number": 3,
"issue": {
"id": 5267,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Test",
"labels": [],
"milestone": null,
"assignee": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"state": "open",
"comments": 2,
"created_at": "2019-11-17T20:50:48Z",
"updated_at": "2019-11-17T22:59:12Z",
"pull_request": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,65 @@
{
"action": "closed",
"number": 3,
"issue": {
"id": 5267,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Closed #3",
"labels": [],
"milestone": null,
"assignee": null,
"state": "closed",
"comments": 1,
"created_at": "2019-11-17T20:50:48Z",
"updated_at": "2019-11-17T20:51:01Z",
"pull_request": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 1,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,70 @@
{
"action": "edited",
"number": 3,
"issue": {
"id": 5268,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Test edit",
"labels": [],
"milestone": null,
"assignee": null,
"state": "open",
"comments": 0,
"created_at": "2019-11-17T21:52:57Z",
"updated_at": "2019-11-17T21:52:57Z",
"pull_request": null
},
"changes": {
"body": {
"from": ""
}
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 1,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,65 @@
{
"action": "opened",
"number": 3,
"issue": {
"id": 5267,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Test",
"labels": [],
"milestone": null,
"assignee": null,
"state": "open",
"comments": 0,
"created_at": "0001-01-01T00:00:00Z",
"updated_at": "0001-01-01T00:00:00Z",
"pull_request": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 0,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,65 @@
{
"action": "reopened",
"number": 3,
"issue": {
"id": 5267,
"number": 3,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "New test issue",
"body": "Test",
"labels": [],
"milestone": null,
"assignee": null,
"state": "open",
"comments": 2,
"created_at": "2019-11-17T20:50:48Z",
"updated_at": "2019-11-17T20:51:06Z",
"pull_request": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 1,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,139 @@
{
"action": "assigned",
"number": 2,
"pull_request": {
"id": 1349,
"number": 2,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "Test",
"body": "",
"labels": [],
"milestone": null,
"assignee": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"state": "open",
"comments": 3,
"head_branch": "c",
"head_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"base_branch": "master",
"base_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"html_url": "https://try.gogs.io/kostekIV/test/pulls/2",
"mergeable": false,
"merged": false,
"merged_at": null,
"merge_commit_sha": null,
"merged_by": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,137 @@
{
"action": "edited",
"number": 2,
"pull_request": {
"id": 1349,
"number": 2,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "Test",
"body": "",
"labels": [],
"milestone": null,
"assignee": null,
"state": "open",
"comments": 3,
"head_branch": "c",
"head_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"base_branch": "master",
"base_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"html_url": "https://try.gogs.io/kostekIV/test/pulls/2",
"mergeable": false,
"merged": false,
"merged_at": null,
"merge_commit_sha": null,
"merged_by": null
},
"changes": {
"title": {
"from": "23r"
}
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,132 @@
{
"action": "reopened",
"number": 2,
"pull_request": {
"id": 1349,
"number": 2,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "reopened",
"body": "",
"labels": [],
"milestone": null,
"assignee": null,
"state": "open",
"comments": 2,
"head_branch": "c",
"head_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 0,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"base_branch": "master",
"base_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 0,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"html_url": "https://try.gogs.io/kostekIV/test/pulls/2",
"mergeable": null,
"merged": false,
"merged_at": null,
"merge_commit_sha": null,
"merged_by": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 40960,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 0,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 0,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-16T08:12:33Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -0,0 +1,139 @@
{
"action": "synchronized",
"number": 2,
"pull_request": {
"id": 1349,
"number": 2,
"user": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"title": "Test",
"body": "",
"labels": [],
"milestone": null,
"assignee": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"state": "open",
"comments": 3,
"head_branch": "c",
"head_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 49152,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-17T23:18:17Z"
},
"base_branch": "master",
"base_repo": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 49152,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-17T23:18:17Z"
},
"html_url": "https://try.gogs.io/kostekIV/test/pulls/2",
"mergeable": false,
"merged": false,
"merged_at": null,
"merge_commit_sha": null,
"merged_by": null
},
"repository": {
"id": 23925,
"owner": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
},
"name": "test",
"full_name": "kostekIV/test",
"description": "",
"private": false,
"fork": false,
"parent": null,
"empty": false,
"mirror": false,
"size": 49152,
"html_url": "https://try.gogs.io/kostekIV/test",
"ssh_url": "git@try.gogs.io:kostekIV/test.git",
"clone_url": "https://try.gogs.io/kostekIV/test.git",
"website": "",
"stars_count": 1,
"forks_count": 0,
"watchers_count": 1,
"open_issues_count": 2,
"default_branch": "master",
"created_at": "2019-11-16T08:08:03Z",
"updated_at": "2019-11-17T23:18:17Z"
},
"sender": {
"id": 43132,
"username": "kostekIV",
"login": "kostekIV",
"full_name": "",
"email": "koscis.j@gmail.com",
"avatar_url": "https://secure.gravatar.com/avatar/91fe35565bf6198f03688b89fdb0a19a?d=identicon"
}
}

View File

@ -82,6 +82,61 @@ class GogsHookTests(WebhookTestCase):
expected_message = u"""john merged [PR #2](http://localhost:3000/john/try-git/pulls/2) from `feature` to `master`."""
self.send_and_test_stream_message('pull_request__merged', expected_topic, expected_message)
def test_pull_request_reopened(self) -> None:
expected_topic = u"test / PR #1349 reopened"
expected_message = u"""kostekIV reopened [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__reopened', expected_topic, expected_message)
def test_pull_request_edited(self) -> None:
expected_topic = u"test / PR #1349 Test"
expected_message = u"""kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__edited', expected_topic, expected_message)
def test_pull_request_assigned(self) -> None:
expected_topic = u"test / PR #1349 Test"
expected_message = u"""kostekIV assigned [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message)
def test_pull_request_synchronized(self) -> None:
expected_topic = u"test / PR #1349 Test"
expected_message = u"""kostekIV synchronized [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__synchronized', expected_topic, expected_message)
def test_issues_opened(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV opened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~"""
self.send_and_test_stream_message('issues__opened', expected_topic, expected_message)
def test_issues_reopened(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV reopened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~"""
self.send_and_test_stream_message('issues__reopened', expected_topic, expected_message)
def test_issues_edited(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV edited [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest edit\n~~~"""
self.send_and_test_stream_message('issues__edited', expected_topic, expected_message)
def test_issues_assignee(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV assigned [Issue #3](https://try.gogs.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest\n~~~"""
self.send_and_test_stream_message('issues__assigned', expected_topic, expected_message)
def test_issues_closed(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV closed [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nClosed #3\n~~~"""
self.send_and_test_stream_message('issues__closed', expected_topic, expected_message)
def test_issue_comment_new(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV [commented](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3635) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest comment\n~~~"""
self.send_and_test_stream_message('issue_comment__new', expected_topic, expected_message)
def test_issue_comment_edited(self) -> None:
expected_topic = u"test / Issue #3 New test issue"
expected_message = u"""kostekIV edited a [comment](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3634) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit comment\n~~~"""
self.send_and_test_stream_message('issue_comment__edited', expected_topic, expected_message)
@patch('zerver.webhooks.gogs.view.check_send_webhook_message')
def test_push_filtered_by_branches_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:
self.url = self.build_webhook_url(branches='changes,development')

View File

@ -12,11 +12,15 @@ from zerver.lib.webhooks.common import check_send_webhook_message, \
get_http_headers_from_filename
from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \
TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE, get_create_branch_event_message, \
get_pull_request_event_message, get_push_commits_event_message
get_pull_request_event_message, get_push_commits_event_message, \
get_issue_event_message
from zerver.models import UserProfile
fixture_to_headers = get_http_headers_from_filename("HTTP_X_GOGS_EVENT")
def get_issue_url(repo_url: str, issue_nr: int) -> str:
return "{}/issues/{}".format(repo_url, issue_nr)
def format_push_event(payload: Dict[str, Any]) -> str:
for commit in payload['commits']:
@ -64,6 +68,39 @@ def format_pull_request_event(payload: Dict[str, Any],
return get_pull_request_event_message(**data)
def format_issues_event(payload: Dict[str, Any], include_title: Optional[bool]=False) -> str:
issue_nr = payload['issue']['number']
assignee = payload['issue']['assignee']
return get_issue_event_message(
payload['sender']['login'],
payload['action'],
get_issue_url(payload['repository']['html_url'], issue_nr),
issue_nr,
payload['issue']['body'],
assignee=assignee['login'] if assignee else None,
title=payload['issue']['title'] if include_title else None
)
def format_issue_comment_event(payload: Dict[str, Any], include_title: Optional[bool]=False) -> str:
action = payload['action']
comment = payload['comment']
issue = payload['issue']
if action == 'created':
action = '[commented]'
else:
action = '{} a [comment]'.format(action)
action += '({}) on'.format(comment['html_url'])
return get_issue_event_message(
payload['sender']['login'],
action,
get_issue_url(payload['repository']['html_url'], issue['number']),
issue['number'],
comment['body'],
title=issue['title'] if include_title else None
)
@api_key_only_webhook_view('Gogs')
@has_request_variables
def api_gogs_webhook(request: HttpRequest, user_profile: UserProfile,
@ -75,7 +112,7 @@ def api_gogs_webhook(request: HttpRequest, user_profile: UserProfile,
event = validate_extract_webhook_http_header(request, 'X_GOGS_EVENT', 'Gogs')
if event == 'push':
branch = payload['ref'].replace('refs/heads/', '')
if branches is not None and branches.find(branch) == -1:
if branches is not None and branch not in branches.split(','):
return json_success()
body = format_push_event(payload)
topic = TOPIC_WITH_BRANCH_TEMPLATE.format(
@ -99,6 +136,28 @@ def api_gogs_webhook(request: HttpRequest, user_profile: UserProfile,
id=payload['pull_request']['id'],
title=payload['pull_request']['title']
)
elif event == 'issues':
body = format_issues_event(
payload,
include_title=user_specified_topic is not None
)
topic = TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
repo=repo,
type='Issue',
id=payload['issue']['number'],
title=payload['issue']['title']
)
elif event == 'issue_comment':
body = format_issue_comment_event(
payload,
include_title=user_specified_topic is not None
)
topic = TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
repo=repo,
type='Issue',
id=payload['issue']['number'],
title=payload['issue']['title']
)
else:
raise UnexpectedWebhookEventType('Gogs', event)