From c2fb80c28244261ed0c2ea4394dcfc2bb2724ded Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 8 Oct 2013 14:45:05 -0400 Subject: [PATCH] git integration: Linkify our commits to point to GitLab. (imported from commit e8d3c107842680dec9bc6aa84f9548c0f879785d) --- bots/zulip_git_config.py | 8 ++++++++ integrations/git/post-receive | 9 ++++++--- integrations/git/zulip_git_config.py | 8 ++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/bots/zulip_git_config.py b/bots/zulip_git_config.py index 6ade66d..6727ea2 100644 --- a/bots/zulip_git_config.py +++ b/bots/zulip_git_config.py @@ -30,5 +30,13 @@ def commit_notice_destination(repo, branch, commit): # Return None for cases where you don't want a notice sent return None +# Modify this function to change how commits are displayed; the most +# common customization is to include a link to the commit in your +# graphical repository viewer, e.g. +# +# return '!gravatar(%s) [%s](https://example.com/commits/%s)\n' % (author, subject, commit_id) +def format_commit_message(author, subject, commit_id): + return '!gravatar(%s) [%s](https://git.zulip.net/eng/zulip/commit/%s)\n' % (author, subject, commit_id) + ZULIP_API_PATH = "/home/zulip/zulip/api" ZULIP_SITE = "https://staging.zulip.com" diff --git a/integrations/git/post-receive b/integrations/git/post-receive index 0424d0f..e58b116 100755 --- a/integrations/git/post-receive +++ b/integrations/git/post-receive @@ -70,11 +70,14 @@ def git_repository_name(): def git_commit_range(oldrev, newrev): log_cmd = ["git", "log", "--reverse", - "--pretty=%aE %s", "%s..%s" % (oldrev, newrev)] + "--pretty=%aE %H %s", "%s..%s" % (oldrev, newrev)] commits = '' for ln in subprocess.check_output(log_cmd).splitlines(): - email, subject = ln.split(None, 1) - commits += '!gravatar(%s) %s\n' % (email, subject) + author_email, commit_id, subject = ln.split(None, 2) + if hasattr(config, "format_commit_message"): + commits += config.format_commit_message(author_email, subject, commit_id) + else: + commits += '!gravatar(%s) %s\n' % (author_email, subject) return commits def send_bot_message(oldrev, newrev, refname): diff --git a/integrations/git/zulip_git_config.py b/integrations/git/zulip_git_config.py index 0093b3a..e2f8d88 100644 --- a/integrations/git/zulip_git_config.py +++ b/integrations/git/zulip_git_config.py @@ -49,6 +49,14 @@ def commit_notice_destination(repo, branch, commit): # Return None for cases where you don't want a notice sent return None +# Modify this function to change how commits are displayed; the most +# common customization is to include a link to the commit in your +# graphical repository viewer, e.g. +# +# return '!gravatar(%s) [%s](https://example.com/commits/%s)\n' % (author, subject, commit_id) +def format_commit_message(author, subject, commit_id): + return '!gravatar(%s) %s\n' % (author, subject) + ## If properly installed, the Zulip API should be in your import ## path, but if not, set a custom path below ZULIP_API_PATH = None