source: darkpeak-services/roles/git/templates/commit-links.sh.j2 @ 55e0291f

ansiblekeycloakmatrixpleroma
Last change on this file since 55e0291f was 55e0291f, checked in by Mat Booth <mat.booth@…>, 2 years ago

Fixes #27 - Ticket references in commit log messages should be linkified

Implemented commit-msg filter for cgit to parse messages for ticket
numbers and commit hashs and linkify them

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#!/bin/sh
2# This script is used to generate links in commit messages.
3#
4# The following environment variables can be used to retrieve the configuration
5# of the repository for which this script is called:
6# CGIT_REPO_URL        ( = repo.url       setting )
7# CGIT_REPO_NAME       ( = repo.name      setting )
8# CGIT_REPO_PATH       ( = repo.path      setting )
9# CGIT_REPO_OWNER      ( = repo.owner     setting )
10# CGIT_REPO_DEFBRANCH  ( = repo.defbranch setting )
11# CGIT_REPO_SECTION    ( = section        setting )
12# CGIT_REPO_CLONE_URL  ( = repo.clone-url setting )
13#
14
15regex=''
16
17# This expression generates links to commits in the same repository, referenced
18# by their SHA sum.
19# Sometimes we might accidentally linkify 7+ letter long words that don't
20# correspond to a valid commit, but it will hopefully happen infrequently enough
21# to not be a problem in real life.
22regex=$regex'
23s|\b([0-9a-fA-F]{7,40})\b|<a href="./?id=\1">\1</a>|g'
24
25# This expression generates links to the main co-op issue tracker, but only for
26# dark peak repositories, not user repositories.
27if [ "$CGIT_REPO_SECTION" = "darkpeak" ] ; then
28        regex=$regex'
29        s|(#\|\bbug\s+\|\bissue\s+\|\bticket\s+)([0-9]+)\b|<a href="https://issues.{{ domain_name }}/ticket/\2">\1\2</a>|g'
30fi
31
32sed -re "$regex"
33
Note: See TracBrowser for help on using the repository browser.