From d17f6dee4130334d9c986fb87bc528eba09de1b9 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 30 Jul 2017 07:41:54 +0100 Subject: [PATCH] Add shortened git commit url to update msgs --- dave/dave.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/dave/dave.py b/dave/dave.py index ca00757..deff98d 100644 --- a/dave/dave.py +++ b/dave/dave.py @@ -12,6 +12,7 @@ import dave.modules as modules import re import subprocess import dave.config as config +import requests from twisted.internet import reactor, task from twisted.internet.threads import deferToThread @@ -129,13 +130,27 @@ def autopull(): output = subprocess.check_output(args).split(b",") log.msg("Pulled latest commit.") - msg = "{} ({}) authored by {} ({}) {}".format( + # get a shortened git commit url + try: + r = requests.post('https://git.io/', { + "url": "https://github.com/{}/commit/{}".format( + config.config["repo"], + str(output[0], 'utf-8') + ) + }, allow_redirects=False, timeout=3) + + commit = r.headers['Location'] + except: + commit = "" + + msg = "{} ({}) authored by {} ({}) {} {}".format( str(output[1], 'utf-8'), str(output[0], 'utf-8'), str(output[3], 'utf-8'), str(output[4], 'utf-8'), naturaltime(datetime.utcnow().timestamp() - - float(output[2])) + float(output[2])), + commit ) log.msg("Updated, {}".format(msg)) -- libgit2 1.7.2