Version 2 (modified by ante, 8 years ago) (diff)

--

Toc?

Postavi na push serveru git config

[trac]
	env-path = /home/pakel/trac/sites/pisarnica
        reponame = gitrepo

Napravi git hook post-receive unutar tog repozitorija

Unutar hooks folder se kreira datoteka post-receive (možda je dobro chmod a+x napraviti da se može executati)

#! /bin/sh
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Edgewall Software
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.com/license.html.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/.
#
# For each Git repository that has to be monitored by your Trac
# environment, you need to modify the hooks in order to call the
# present script:
#
# Configurations using git-config
# -------------------------------
# trac.env-path
#       Path to your Trac environment.
# trac.admin-path
#       Optional, path to trac-admin command. The default is "trac-admin".
# trac.reponame
#       Optional, repository name in your Trac environment. The default
#       is "(default)".
#

tracenv="`git config trac.env-path`"
if [ -z "$tracenv" ]; then
    echo "trac.env-path is missing" 1>&2
    exit
fi
if [ ! -r "$tracenv/VERSION" ]; then
    echo "'$tracenv' doesn't seem to be a Trac environment" 1>&2
    exit
fi
tracadmin="`git config trac.admin-path`"
[ -z "$tracadmin" ] && tracadmin=trac-admin
reponame="`git config trac.reponame`"
[ -z "$reponame" ] && reponame='(default)'
log="/tmp/mylog.log"

nullrev=0000000000000000000000000000000000000000
grep_args=-vF
changed=0
revlist_args=
while read oldrev newrev refname; do
    grep_args="$grep_args -e $refname"
    if [ $newrev != $nullrev ]; then  # branch is removed
        changed=1
        revlist_args="$revlist_args $newrev"
        if [ $oldrev != $nullrev ]; then  # branch is updated
            revlist_args="$revlist_args ^$oldrev"
        fi
    fi
done

exec >>"$log" 2>&1

if [ $changed = 0 ]; then
    # no new commits, but repository is changed
    nohup "$tracadmin" "$tracenv" repository sync "$reponame" &
else
    refnames="`
        git for-each-ref --format='%(refname)' refs/heads | \
            grep $grep_args`"
    for refname in $refnames; do
        revlist_args="$revlist_args ^$refname"
    done
    echo "[`date`] $revlist >> "$log"
    echo "[`date`] git rev-list --reverse $revlist_args >> "$log"
    echo "[`date`] \"$tracadmin\" \"$tracenv\" changeset added \"$reponame\""  >> "$log"

    nohup $SHELL <<_EOS_ &
        git rev-list --reverse $revlist_args | \
            xargs "$tracadmin" "$tracenv" changeset added "$reponame"
_EOS_
fi

Dodaj git repo kroz trac

  • Ukljući podršku za git (admin plugins Trac)
  • Uključi Ticket Commit updater (admin plugins Trac)
    • CommitTicketReferenceMacro
    • CommitTicketUpdater