aboutsummaryrefslogtreecommitdiff
path: root/modules/github.py
blob: 45c73619c0e3f9a225f22d19b06235824a583e13 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
from src import ModuleManager, utils

class Module(ModuleManager.BaseModule):
    @utils.hook("api.post.github")
    def github(self, event):
        data = event["data"]
        try:
            data = json.loads(data)
        except:
            return

        if "commits" in data:
            full_name = data["repository"]["full_name"]

            for commit in data["commits"]:
                id = commit["id"]
                message = commit["message"]
                author = "%s <%s>" % (commit["author"]["username"],
                    commit["author"]["email"])
                modified_count = len(commit["modified"])
                added_count = len(commit["added"])
                removed_count = len(commit["removed"])

                print("(%s) [%d/%d/%d mod/add/del] commit by %s: %s" % (
                    full_name, modified_count, added_count, removed_count,
                    author, message))