From 20056690507c2a69bfdb307ae5ade414dac5a795 Mon Sep 17 00:00:00 2001 From: kongr45gpen Date: Mon, 13 Nov 2017 01:26:35 +0200 Subject: Improve issues theme Closes #10 Closes #11 --- local/theme/DefaultTheme.py | 18 +++- local/utility.py | 9 +- samples/issue-assign-self.json | 240 +++++++++++++++++++++++++++++++++++++++++ samples/issue-unlabel.json | 207 +++++++++++++++++++++++++++++++++++ samples/label-create.json | 119 ++++++++++++++++++++ test.py | 13 +++ 6 files changed, 599 insertions(+), 7 deletions(-) create mode 100644 samples/issue-assign-self.json create mode 100644 samples/issue-unlabel.json create mode 100644 samples/label-create.json diff --git a/local/theme/DefaultTheme.py b/local/theme/DefaultTheme.py index d9ee11a..dbb8128 100644 --- a/local/theme/DefaultTheme.py +++ b/local/theme/DefaultTheme.py @@ -83,18 +83,30 @@ class DefaultTheme(Theme): formattedActor = ircutils.bold(formattedActor) extra = '' + formattedFiller = type if action == 'assigned': - extra = " to %s" % ircutils.bold(ircutils.mircColor(assignee, "green")) + if assignee == actor: + # Don't show assignee name twice + action = 'self-assigned' + else: + extra = " to %s" % ircutils.bold(ircutils.mircColor(assignee, "green")) elif action == 'unassigned': extra = " from %s" % ircutils.mircColor(assignee, "green") - elif action == 'labeled' or action == 'unlabeled': + elif action == 'labeled': + # This is not the same syntax as 'unlabeled', since adding a label + # is a more frequent action than removing one, and adding more + # filler text would make the message harder to read extra = " as %s" % ircutils.mircColor(labelName, hexToMirc(labelColor)) + elif action == 'unlabeled': + # Grammar gets weird here + action = 'removed' + formattedFiller = "%s label from" % ircutils.mircColor(labelName, hexToMirc(labelColor)) self.msgs.append( "%s: %s %s %s #%s%s%s%s %s%s" % ( self.repo(), formattedActor, colorAction(action), - type, + formattedFiller, issueNo, " \"%s\"" % (ircutils.bold(issueTitle)) if showName else '', " by %s" % ircutils.mircColor(creator,"green") if creator != actor else '', diff --git a/local/utility.py b/local/utility.py index 86e1b91..0393ae7 100644 --- a/local/utility.py +++ b/local/utility.py @@ -100,9 +100,9 @@ def maxLen(msg, maxn=400, splitLines=True): ret = msg return ret - +# TODO: Use a better data structure for this? def colorAction(action): - """Give an action string (e.g. created, edited) and get a nice IRC colouring""" + """Give an action string (e.g. created, edited) and get a nice IRC colouring.""" # Fix past tense for some github verbs if action in ["synchronize"]: @@ -113,9 +113,10 @@ def colorAction(action): return ircutils.bold(ircutils.mircColor(action, "green")) if action in ["deleted", "closed", "re-tagged", "deleted tag", "failed", "errored", "failure", "still failing", - "broken", "error"]: + "broken", "error", "removed"]: return ircutils.bold(ircutils.mircColor(action, "red")) - if action in ["assigned", "merged", "synchronized"]: + if action in ["assigned", "self-assigned", "merged", "synchronized", + "labeled"]: return ircutils.bold(ircutils.mircColor(action, "light blue")) if action in ["reopened", "pending"]: return ircutils.bold(ircutils.mircColor(action, "blue")) diff --git a/samples/issue-assign-self.json b/samples/issue-assign-self.json new file mode 100644 index 0000000..78cc2cc --- /dev/null +++ b/samples/issue-assign-self.json @@ -0,0 +1,240 @@ +{ + "action": "assigned", + "issue": { + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/22", + "repository_url": "https://api.github.com/repos/kongr45gpen/supybot-github", + "labels_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/22/labels{/name}", + "comments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/22/comments", + "events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/22/events", + "html_url": "https://github.com/kongr45gpen/supybot-github/issues/22", + "id": 273274259, + "number": 22, + "title": "Handle duplicate notifications for branches and tags", + "user": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 48907776, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/enhancement", + "name": "enhancement", + "color": "84b6eb", + "default": true + }, + { + "id": 748352642, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/high-priority", + "name": "high-priority", + "color": "e99695", + "default": false + }, + { + "id": 748352553, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/low-priority", + "name": "low-priority", + "color": "c2e0c6", + "default": false + }, + { + "id": 480433492, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/under-consideration", + "name": "under-consideration", + "color": "fbca04", + "default": false + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 0, + "created_at": "2017-11-12T23:04:16Z", + "updated_at": "2017-11-12T23:04:16Z", + "closed_at": null, + "author_association": "OWNER", + "body": "" + }, + "assignee": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "repository": { + "id": 11590921, + "name": "supybot-github", + "full_name": "kongr45gpen/supybot-github", + "owner": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/kongr45gpen/supybot-github", + "description": "Highly configurable and beta limnoria/supybot IRC bot plugin that uses an HTTP webhooks to report commits and other updates from Github repositories", + "fork": false, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github", + "forks_url": "https://api.github.com/repos/kongr45gpen/supybot-github/forks", + "keys_url": "https://api.github.com/repos/kongr45gpen/supybot-github/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kongr45gpen/supybot-github/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kongr45gpen/supybot-github/teams", + "hooks_url": "https://api.github.com/repos/kongr45gpen/supybot-github/hooks", + "issue_events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/events{/number}", + "events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/events", + "assignees_url": "https://api.github.com/repos/kongr45gpen/supybot-github/assignees{/user}", + "branches_url": "https://api.github.com/repos/kongr45gpen/supybot-github/branches{/branch}", + "tags_url": "https://api.github.com/repos/kongr45gpen/supybot-github/tags", + "blobs_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kongr45gpen/supybot-github/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kongr45gpen/supybot-github/languages", + "stargazers_url": "https://api.github.com/repos/kongr45gpen/supybot-github/stargazers", + "contributors_url": "https://api.github.com/repos/kongr45gpen/supybot-github/contributors", + "subscribers_url": "https://api.github.com/repos/kongr45gpen/supybot-github/subscribers", + "subscription_url": "https://api.github.com/repos/kongr45gpen/supybot-github/subscription", + "commits_url": "https://api.github.com/repos/kongr45gpen/supybot-github/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kongr45gpen/supybot-github/contents/{+path}", + "compare_url": "https://api.github.com/repos/kongr45gpen/supybot-github/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kongr45gpen/supybot-github/merges", + "archive_url": "https://api.github.com/repos/kongr45gpen/supybot-github/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kongr45gpen/supybot-github/downloads", + "issues_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues{/number}", + "pulls_url": "https://api.github.com/repos/kongr45gpen/supybot-github/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kongr45gpen/supybot-github/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kongr45gpen/supybot-github/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels{/name}", + "releases_url": "https://api.github.com/repos/kongr45gpen/supybot-github/releases{/id}", + "deployments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/deployments", + "created_at": "2013-07-22T19:55:10Z", + "updated_at": "2017-08-25T22:14:26Z", + "pushed_at": "2017-11-12T23:01:46Z", + "git_url": "git://github.com/kongr45gpen/supybot-github.git", + "ssh_url": "git@github.com:kongr45gpen/supybot-github.git", + "clone_url": "https://github.com/kongr45gpen/supybot-github.git", + "svn_url": "https://github.com/kongr45gpen/supybot-github", + "homepage": "http://supybot-github.readthedocs.org/", + "size": 397, + "stargazers_count": 3, + "watchers_count": 3, + "language": "Python", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 15, + "forks": 0, + "open_issues": 15, + "watchers": 3, + "default_branch": "master" + }, + "sender": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/samples/issue-unlabel.json b/samples/issue-unlabel.json new file mode 100644 index 0000000..e0472c0 --- /dev/null +++ b/samples/issue-unlabel.json @@ -0,0 +1,207 @@ +{ + "action": "unlabeled", + "issue": { + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/14", + "repository_url": "https://api.github.com/repos/kongr45gpen/supybot-github", + "labels_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/14/labels{/name}", + "comments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/14/comments", + "events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/14/events", + "html_url": "https://github.com/kongr45gpen/supybot-github/issues/14", + "id": 196914079, + "number": 14, + "title": "Properly display edited comments", + "user": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 48907774, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/bug", + "name": "bug", + "color": "fc2929", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 0, + "created_at": "2016-12-21T11:51:41Z", + "updated_at": "2017-11-12T23:05:46Z", + "closed_at": null, + "author_association": "OWNER", + "body": "" + }, + "label": { + "id": 748352553, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/low-priority", + "name": "low-priority", + "color": "c2e0c6", + "default": false + }, + "repository": { + "id": 11590921, + "name": "supybot-github", + "full_name": "kongr45gpen/supybot-github", + "owner": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/kongr45gpen/supybot-github", + "description": "Highly configurable and beta limnoria/supybot IRC bot plugin that uses an HTTP webhooks to report commits and other updates from Github repositories", + "fork": false, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github", + "forks_url": "https://api.github.com/repos/kongr45gpen/supybot-github/forks", + "keys_url": "https://api.github.com/repos/kongr45gpen/supybot-github/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kongr45gpen/supybot-github/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kongr45gpen/supybot-github/teams", + "hooks_url": "https://api.github.com/repos/kongr45gpen/supybot-github/hooks", + "issue_events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/events{/number}", + "events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/events", + "assignees_url": "https://api.github.com/repos/kongr45gpen/supybot-github/assignees{/user}", + "branches_url": "https://api.github.com/repos/kongr45gpen/supybot-github/branches{/branch}", + "tags_url": "https://api.github.com/repos/kongr45gpen/supybot-github/tags", + "blobs_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kongr45gpen/supybot-github/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kongr45gpen/supybot-github/languages", + "stargazers_url": "https://api.github.com/repos/kongr45gpen/supybot-github/stargazers", + "contributors_url": "https://api.github.com/repos/kongr45gpen/supybot-github/contributors", + "subscribers_url": "https://api.github.com/repos/kongr45gpen/supybot-github/subscribers", + "subscription_url": "https://api.github.com/repos/kongr45gpen/supybot-github/subscription", + "commits_url": "https://api.github.com/repos/kongr45gpen/supybot-github/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kongr45gpen/supybot-github/contents/{+path}", + "compare_url": "https://api.github.com/repos/kongr45gpen/supybot-github/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kongr45gpen/supybot-github/merges", + "archive_url": "https://api.github.com/repos/kongr45gpen/supybot-github/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kongr45gpen/supybot-github/downloads", + "issues_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues{/number}", + "pulls_url": "https://api.github.com/repos/kongr45gpen/supybot-github/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kongr45gpen/supybot-github/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kongr45gpen/supybot-github/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels{/name}", + "releases_url": "https://api.github.com/repos/kongr45gpen/supybot-github/releases{/id}", + "deployments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/deployments", + "created_at": "2013-07-22T19:55:10Z", + "updated_at": "2017-08-25T22:14:26Z", + "pushed_at": "2017-11-12T23:01:46Z", + "git_url": "git://github.com/kongr45gpen/supybot-github.git", + "ssh_url": "git@github.com:kongr45gpen/supybot-github.git", + "clone_url": "https://github.com/kongr45gpen/supybot-github.git", + "svn_url": "https://github.com/kongr45gpen/supybot-github", + "homepage": "http://supybot-github.readthedocs.org/", + "size": 397, + "stargazers_count": 3, + "watchers_count": 3, + "language": "Python", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 15, + "forks": 0, + "open_issues": 15, + "watchers": 3, + "default_branch": "master" + }, + "sender": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/samples/label-create.json b/samples/label-create.json new file mode 100644 index 0000000..e7b134c --- /dev/null +++ b/samples/label-create.json @@ -0,0 +1,119 @@ +{ + "action": "created", + "label": { + "id": 748352642, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels/high-priority", + "name": "high-priority", + "color": "e99695", + "default": false + }, + "repository": { + "id": 11590921, + "name": "supybot-github", + "full_name": "kongr45gpen/supybot-github", + "owner": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/kongr45gpen/supybot-github", + "description": "Highly configurable and beta limnoria/supybot IRC bot plugin that uses an HTTP webhooks to report commits and other updates from Github repositories", + "fork": false, + "url": "https://api.github.com/repos/kongr45gpen/supybot-github", + "forks_url": "https://api.github.com/repos/kongr45gpen/supybot-github/forks", + "keys_url": "https://api.github.com/repos/kongr45gpen/supybot-github/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/kongr45gpen/supybot-github/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/kongr45gpen/supybot-github/teams", + "hooks_url": "https://api.github.com/repos/kongr45gpen/supybot-github/hooks", + "issue_events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/events{/number}", + "events_url": "https://api.github.com/repos/kongr45gpen/supybot-github/events", + "assignees_url": "https://api.github.com/repos/kongr45gpen/supybot-github/assignees{/user}", + "branches_url": "https://api.github.com/repos/kongr45gpen/supybot-github/branches{/branch}", + "tags_url": "https://api.github.com/repos/kongr45gpen/supybot-github/tags", + "blobs_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/kongr45gpen/supybot-github/statuses/{sha}", + "languages_url": "https://api.github.com/repos/kongr45gpen/supybot-github/languages", + "stargazers_url": "https://api.github.com/repos/kongr45gpen/supybot-github/stargazers", + "contributors_url": "https://api.github.com/repos/kongr45gpen/supybot-github/contributors", + "subscribers_url": "https://api.github.com/repos/kongr45gpen/supybot-github/subscribers", + "subscription_url": "https://api.github.com/repos/kongr45gpen/supybot-github/subscription", + "commits_url": "https://api.github.com/repos/kongr45gpen/supybot-github/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/kongr45gpen/supybot-github/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/kongr45gpen/supybot-github/contents/{+path}", + "compare_url": "https://api.github.com/repos/kongr45gpen/supybot-github/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/kongr45gpen/supybot-github/merges", + "archive_url": "https://api.github.com/repos/kongr45gpen/supybot-github/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/kongr45gpen/supybot-github/downloads", + "issues_url": "https://api.github.com/repos/kongr45gpen/supybot-github/issues{/number}", + "pulls_url": "https://api.github.com/repos/kongr45gpen/supybot-github/pulls{/number}", + "milestones_url": "https://api.github.com/repos/kongr45gpen/supybot-github/milestones{/number}", + "notifications_url": "https://api.github.com/repos/kongr45gpen/supybot-github/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/kongr45gpen/supybot-github/labels{/name}", + "releases_url": "https://api.github.com/repos/kongr45gpen/supybot-github/releases{/id}", + "deployments_url": "https://api.github.com/repos/kongr45gpen/supybot-github/deployments", + "created_at": "2013-07-22T19:55:10Z", + "updated_at": "2017-08-25T22:14:26Z", + "pushed_at": "2017-11-12T23:01:46Z", + "git_url": "git://github.com/kongr45gpen/supybot-github.git", + "ssh_url": "git@github.com:kongr45gpen/supybot-github.git", + "clone_url": "https://github.com/kongr45gpen/supybot-github.git", + "svn_url": "https://github.com/kongr45gpen/supybot-github", + "homepage": "http://supybot-github.readthedocs.org/", + "size": 397, + "stargazers_count": 3, + "watchers_count": 3, + "language": "Python", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "open_issues_count": 14, + "forks": 0, + "open_issues": 14, + "watchers": 3, + "default_branch": "master" + }, + "sender": { + "login": "kongr45gpen", + "id": 720678, + "avatar_url": "https://avatars3.githubusercontent.com/u/720678?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kongr45gpen", + "html_url": "https://github.com/kongr45gpen", + "followers_url": "https://api.github.com/users/kongr45gpen/followers", + "following_url": "https://api.github.com/users/kongr45gpen/following{/other_user}", + "gists_url": "https://api.github.com/users/kongr45gpen/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kongr45gpen/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kongr45gpen/subscriptions", + "organizations_url": "https://api.github.com/users/kongr45gpen/orgs", + "repos_url": "https://api.github.com/users/kongr45gpen/repos", + "events_url": "https://api.github.com/users/kongr45gpen/events{/privacy}", + "received_events_url": "https://api.github.com/users/kongr45gpen/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/test.py b/test.py index 9300ca6..443f548 100644 --- a/test.py +++ b/test.py @@ -202,6 +202,19 @@ class GithubTestCase(ExpectationPluginTestCase): it().should.contain('https://github.com/kongr45gpen/test/issues/6#issuecomment-181134370') ) + def testIssueSelfAssign(self): + self.sendRequest('issue-assign-self') + + self.describe('first message', + it().should.contain('kongr45gpen'), + it().should.contain('supybot-github'), + it().should.contain('self-assigned'), + it().should.contain('issue'), + it().should.contain('#22'), + it().should.contain('Handle duplicate notifications for branches and tags'), + it().should.contain('https://github.com/kongr45gpen/supybot-github/issues/22') + ) + def testPullRequestCreate(self): self.sendRequest('pr-create') -- cgit v1.2.3