mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-04 01:10:59 -05:00
GitLab: s/Gitlab/GitLab/g
This commit is contained in:
parent
6382b9d197
commit
726ac377ed
@ -29,7 +29,7 @@
|
||||
###
|
||||
|
||||
"""
|
||||
Gitlab: Plugin for communication and notifications with a Gitlab instance
|
||||
GitLab: Plugin for communication and notifications with a GitLab instance
|
||||
"""
|
||||
|
||||
import supybot
|
||||
|
@ -32,7 +32,7 @@ import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
_ = PluginInternationalization('Gitlab')
|
||||
_ = PluginInternationalization('GitLab')
|
||||
except:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
@ -45,70 +45,70 @@ def configure(advanced):
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Gitlab', True)
|
||||
conf.registerPlugin('GitLab', True)
|
||||
|
||||
|
||||
Gitlab = conf.registerPlugin('Gitlab')
|
||||
GitLab = conf.registerPlugin('GitLab')
|
||||
|
||||
# Settings
|
||||
conf.registerChannelValue(Gitlab, 'projects',
|
||||
conf.registerChannelValue(GitLab, 'projects',
|
||||
registry.Json({}, _("""List of projects""")))
|
||||
|
||||
# Format
|
||||
conf.registerGroup(Gitlab, 'format')
|
||||
conf.registerGroup(GitLab, 'format')
|
||||
|
||||
conf.registerChannelValue(Gitlab, 'use-notices',
|
||||
conf.registerChannelValue(GitLab, 'use-notices',
|
||||
registry.Boolean(False, _("""Determines whether the bot should announce using NOTICE instead of PRIVMSG.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'push',
|
||||
conf.registerChannelValue(GitLab.format, 'push',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {user_name} pushed \x02{total_commits_count} commit(s)\x02 to \x02{ref}\x02:"""),
|
||||
_("""Format for push events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'commit',
|
||||
conf.registerChannelValue(GitLab.format, 'commit',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {short_id} \x02{short_message}\x02 by {author[name]}"""),
|
||||
_("""Format for commits.""")))
|
||||
|
||||
conf.registerChannelValue(Gitlab.format, 'tag',
|
||||
conf.registerChannelValue(GitLab.format, 'tag',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {user_name} created a new tag {ref}"""),
|
||||
_("""Format for tag push events.""")))
|
||||
|
||||
conf.registerChannelValue(Gitlab.format, 'issue-open',
|
||||
conf.registerChannelValue(GitLab.format, 'issue-open',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Issue \x02#{issue[id]} {issue[title]}\x02 created by {user[name]} {issue[url]}"""),
|
||||
_("""Format for issue/open events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'issue-update',
|
||||
conf.registerChannelValue(GitLab.format, 'issue-update',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Issue \x02#{issue[id]} {issue[title]}\x02 updated by {user[name]} {issue[url]}"""),
|
||||
_("""Format for issue/update events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'issue-close',
|
||||
conf.registerChannelValue(GitLab.format, 'issue-close',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Issue \x02#{issue[id]} {issue[title]}\x02 closed by {user[name]} {issue[url]}"""),
|
||||
_("""Format for issue/close events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'issue-reopen',
|
||||
conf.registerChannelValue(GitLab.format, 'issue-reopen',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Issue \x02#{issue[id]} {issue[title]}\x02 reopend by {user[name]} {issue[url]}"""),
|
||||
_("""Format for issue/reopen events.""")))
|
||||
|
||||
conf.registerChannelValue(Gitlab.format, 'merge-request-open',
|
||||
conf.registerChannelValue(GitLab.format, 'merge-request-open',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Merge request \x02#{merge_request[id]} {merge_request[title]}\x02 created by {user[name]} {merge_request[url]}"""),
|
||||
_("""Format for merge-request/open events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'merge-request-update',
|
||||
conf.registerChannelValue(GitLab.format, 'merge-request-update',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Merge request \x02#{merge_request[id]} {merge_request[title]}\x02 updated by {user[name]} {merge_request[url]}"""),
|
||||
_("""Format for merge-request/open events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'merge-request-close',
|
||||
conf.registerChannelValue(GitLab.format, 'merge-request-close',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Merge request \x02#{merge_request[id]} {merge_request[title]}\x02 closed by {user[name]} {merge_request[url]}"""),
|
||||
_("""Format for merge-request/open events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'merge-request-reopen',
|
||||
conf.registerChannelValue(GitLab.format, 'merge-request-reopen',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Merge request \x02#{merge_request[id]} {merge_request[title]}\x02 reopened by {user[name]} {merge_request[url]}"""),
|
||||
_("""Format for merge-request/open events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'merge-request-merge',
|
||||
conf.registerChannelValue(GitLab.format, 'merge-request-merge',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 Merge request \x02#{merge_request[id]} {merge_request[title]}\x02 merged by {user[name]} {merge_request[url]}"""),
|
||||
_("""Format for merge-request/open events.""")))
|
||||
|
||||
conf.registerChannelValue(Gitlab.format, 'note-merge-request',
|
||||
conf.registerChannelValue(GitLab.format, 'note-merge-request',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {user[name]} commented on Merge request \x02#{merge_request[id]} {merge_request[title]}\x02 {note[url]}"""),
|
||||
_("""Format for note/merge-request events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'note-commit',
|
||||
conf.registerChannelValue(GitLab.format, 'note-commit',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {user[name]} commented on Commit \x02#{commit[id]}\x02 {commit[url]}"""),
|
||||
_("""Format for note/commit events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'note-issue',
|
||||
conf.registerChannelValue(GitLab.format, 'note-issue',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {user[name]} commented on Issue \x02#{issue[id]} {issue[title]}\x02 {note[url]}"""),
|
||||
_("""Format for note/issue events.""")))
|
||||
conf.registerChannelValue(Gitlab.format, 'note-snippet',
|
||||
conf.registerChannelValue(GitLab.format, 'note-snippet',
|
||||
registry.String(_("""\x02[{project[name]}]\x02 {user[name]} commented on Snippet \x02#{snippet[id]} {snippet[title]}\x02 {note[url]}"""),
|
||||
_("""Format for note/snippet events.""")))
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2015, Moritz Lipp
|
||||
# Copyright (c) 2018-2019, James Lu <james@overdrivenetworks.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -40,7 +41,7 @@ import supybot.world as world
|
||||
try:
|
||||
from supybot.i18n import PluginInternationalization
|
||||
from supybot.i18n import internationalizeDocstring
|
||||
_ = PluginInternationalization('Gitlab')
|
||||
_ = PluginInternationalization('GitLab')
|
||||
except ImportError:
|
||||
# Placeholder that allows to run the plugin on a bot
|
||||
# without the i18n module
|
||||
@ -51,26 +52,26 @@ except ImportError:
|
||||
return x
|
||||
|
||||
|
||||
class GitlabHandler(object):
|
||||
class GitLabHandler(object):
|
||||
|
||||
"""Handle gitlab messages"""
|
||||
|
||||
def __init__(self, plugin):
|
||||
self.plugin = plugin
|
||||
self.log = log.getPluginLogger('Gitlab')
|
||||
self.log = log.getPluginLogger('GitLab')
|
||||
# HACK: instead of refactoring everything, I can just replace this with each handle_payload() call.
|
||||
self.irc = None
|
||||
|
||||
def handle_payload(self, headers, payload, irc):
|
||||
if 'X-Gitlab-Event' not in headers:
|
||||
self.log.info('Invalid header: Missing X-Gitlab-Event entry')
|
||||
if 'X-GitLab-Event' not in headers:
|
||||
self.log.info('Invalid header: Missing X-GitLab-Event entry')
|
||||
return
|
||||
self.irc = irc
|
||||
self.log.debug('GitLab: running on network %r', irc.network)
|
||||
|
||||
event_type = headers['X-Gitlab-Event']
|
||||
event_type = headers['X-GitLab-Event']
|
||||
if event_type not in ['Push Hook', 'Tag Push Hook', 'Note Hook', 'Issue Hook', 'Merge Request Hook']:
|
||||
self.log.info('Unsupported X-Gitlab-Event type')
|
||||
self.log.info('Unsupported X-GitLab-Event type')
|
||||
return
|
||||
|
||||
# Check if any channel has subscribed to this project
|
||||
@ -206,15 +207,15 @@ class GitlabHandler(object):
|
||||
self.irc.queueMsg(announce_msg)
|
||||
|
||||
|
||||
class GitlabWebHookService(httpserver.SupyHTTPServerCallback):
|
||||
class GitLabWebHookService(httpserver.SupyHTTPServerCallback):
|
||||
"""https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/web_hooks/web_hooks.md"""
|
||||
|
||||
name = "GitlabWebHookService"
|
||||
name = "GitLabWebHookService"
|
||||
defaultResponse = """This plugin handles only POST request, please don't use other requests."""
|
||||
|
||||
def __init__(self, plugin):
|
||||
self.log = log.getPluginLogger('Gitlab')
|
||||
self.gitlab = GitlabHandler(plugin)
|
||||
self.log = log.getPluginLogger('GitLab')
|
||||
self.gitlab = GitLabHandler(plugin)
|
||||
self.plugin = plugin
|
||||
|
||||
def _send_error(self, handler, message):
|
||||
@ -266,8 +267,8 @@ class GitlabWebHookService(httpserver.SupyHTTPServerCallback):
|
||||
self._send_ok(handler)
|
||||
|
||||
|
||||
class Gitlab(callbacks.Plugin):
|
||||
"""Plugin for communication and notifications of a Gitlab project
|
||||
class GitLab(callbacks.Plugin):
|
||||
"""Plugin for communication and notifications of a GitLab project
|
||||
management tool instance"""
|
||||
threaded = True
|
||||
|
||||
@ -275,11 +276,11 @@ class Gitlab(callbacks.Plugin):
|
||||
global instance
|
||||
|
||||
# Store the super() information so that reloads don't fail
|
||||
self.__parent = super(Gitlab, self)
|
||||
self.__parent = super(GitLab, self)
|
||||
self.__parent.__init__(irc)
|
||||
instance = self
|
||||
|
||||
callback = GitlabWebHookService(self)
|
||||
callback = GitLabWebHookService(self)
|
||||
httpserver.hook('gitlab', callback)
|
||||
|
||||
def die(self):
|
||||
@ -305,7 +306,7 @@ class Gitlab(callbacks.Plugin):
|
||||
return False
|
||||
|
||||
class gitlab(callbacks.Commands):
|
||||
"""Gitlab commands"""
|
||||
"""GitLab commands"""
|
||||
|
||||
class project(callbacks.Commands):
|
||||
"""Project commands"""
|
||||
@ -378,7 +379,7 @@ class Gitlab(callbacks.Plugin):
|
||||
list = wrap(list, ['channel'])
|
||||
|
||||
|
||||
Class = Gitlab
|
||||
Class = GitLab
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
Loading…
x
Reference in New Issue
Block a user