aboutsummaryrefslogtreecommitdiffstats
path: root/local
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2021-05-31 02:55:01 +0300
committerkongr45gpen <electrovesta@gmail.com>2021-05-31 02:55:01 +0300
commit36694234b4dc84137db2d42ec7701351062f8294 (patch)
tree78b9d82147d85fbf0bb2a61f2217a4f403e16454 /local
parent177832b444b6e4b3737a21af84ba8aa436e5f25a (diff)
downloadsupybot_github-36694234b4dc84137db2d42ec7701351062f8294.tar.gz
supybot_github-36694234b4dc84137db2d42ec7701351062f8294.tar.bz2
supybot_github-36694234b4dc84137db2d42ec7701351062f8294.zip
Add support for gitlab pushes
Diffstat (limited to 'local')
-rw-r--r--local/handler/GithubHandler.py11
-rw-r--r--local/handler/GitlabPushHandler.py33
2 files changed, 42 insertions, 2 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py
index 1e133e6..1e54e67 100644
--- a/local/handler/GithubHandler.py
+++ b/local/handler/GithubHandler.py
@@ -38,6 +38,7 @@ from . import NetlifyHandler
from . import ReleaseHandler
from . import UnknownHandler
from . import AppVeyorHandler
+from . import GitlabPushHandler
from . import CreateDeleteHandler
from . import IssueCommentHandler
@@ -133,9 +134,9 @@ class GithubHandler(http.server.BaseHTTPRequestHandler):
s.wfile.write("Invalid secret key\n".encode())
return
- GithubHandler.process_data(data, channel)
+ GithubHandler.process_data(data, channel, eventType)
- def process_data(data, channel=None):
+ def process_data(data, channel=None, eventType=None):
brackets = parseBrackets(configValue('brackets'))
themeName = configValue('theme')
@@ -170,6 +171,12 @@ class GithubHandler(http.server.BaseHTTPRequestHandler):
TravisHandler.handle(data, theme)
elif 'pages' in data:
WikiHandler.handle(data, theme)
+ elif 'object_kind' in data and 'event_name' in data:
+ if data['event_name'] == "push":
+ GitlabPushHandler.handle(data, theme)
+ else:
+ data['eventType'] = data['event_name']
+ UnknownHandler.handle(data, theme)
elif 'screenshot_url' in data:
NetlifyHandler.handle(data, theme)
elif 'state' in data:
diff --git a/local/handler/GitlabPushHandler.py b/local/handler/GitlabPushHandler.py
new file mode 100644
index 0000000..84574ed
--- /dev/null
+++ b/local/handler/GitlabPushHandler.py
@@ -0,0 +1,33 @@
+from ..utility import *
+
+def handle(data, theme):
+ commitno = len(data['commits'])
+ ref = data['ref'].split('/', 2)
+ branch = ref[2]
+
+ pushVisible = configValue("hidePush") == False
+ pushUrl = "{}/-/compare/{}...{}".format(
+ data['repository']['homepage'],
+ data['before'],
+ data['after']
+ )
+ if pushVisible:
+ theme.push(
+ branch = branch,
+ actor = data['user_username'],
+ url = getShortURL(pushUrl),
+ count = commitno,
+ forced = False
+ )
+
+ for commit in data['commits']:
+ theme.commit(
+ branch = branch,
+ author = commit['author']['name'],
+ id = commit['id'],
+ message = commit['message'],
+ url = getShortURL(commit['url'])
+ )
+
+ return True
+

© 2014-2024 Faster IT GmbH | imprint | privacy policy