Integration with Bugzilla?

Ferry Huberts mailings at hupie.com
Mon Sep 29 20:09:48 CEST 2014



On 29/09/14 19:49, Joey Reid wrote:
> I often run into situations where the git commit log references a
> bugzilla report. Such as this one
>
> http://cgit.freedesktop.org/libreoffice/core/commit/?id=559484d5871c7c0a7e771f75916c46f3a6a590ae
> <http://cgit.freedesktop.org/libreoffice/core/commit/?id=559484d5871c7c0a7e771f75916c46f3a6a590ae>
>
> Where fdo#60123 Refers to
> https://bugs.freedesktop.org/show_bug.cgi?id=60123
>
> or this one where the bug is #i125581#
> https://github.com/apache/openoffice/commit/8cb619bd314a80fe7f7094b16f25d362979f0c69
>
> Is it possible to have cgit parse the subject for fdo#<number> or
> #i<number>#  and replace the plain text with a hyperlink containing
> <number>?
>
>



Sure.

The below script is what I use on my server to refer to a trac ticket.

---
#!/bin/bash

#
# This script can be used to generate links in commit messages.
#
# To use this script, refer to this file with either the commit-filter 
or the
# repo.commit-filter options in cgitrc.
#
# The following environment variables can be used to retrieve the 
configuration
# of the repository for which this script is called:
# CGIT_REPO_URL        ( = repo.url       setting )
# CGIT_REPO_NAME       ( = repo.name      setting )
# CGIT_REPO_PATH       ( = repo.path      setting )
# CGIT_REPO_OWNER      ( = repo.owner     setting )
# CGIT_REPO_DEFBRANCH  ( = repo.defbranch setting )
# CGIT_REPO_SECTION    ( = section        setting )
# CGIT_REPO_CLONE_URL  ( = repo.clone-url setting )
#

declare regex=""

#
# Commit SHA1
#
regex="s|\b([0-9a-fA-F]{7,40})\b|<a href=\"./?id=\1\">\1</a>|g"

#
# Trac
#
# We have a trac instance for every repository,
# located under /reposerf/trac/repoName
#
if [[ -n "${CGIT_REPO_PATH:-}" ]]; then
   regex="$regex
s|#([0-9]+)\b|<a href=\"/reposerf/trac/$(basename 
"${CGIT_REPO_PATH}")/ticket/\1\">#\1</a>|g"
fi

sed -re "$regex"


More information about the CGit mailing list