← Previous ChangeWiki History

Changes between Initial Version and Version 1 of Git


Ignore:
Timestamp:
02/14/18 18:56:55 (8 years ago)
Author:
ante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Git

    v1 v1  
     1[[Toc]]
     2
     3== Postavi na push serveru git config ==
     4
     5{{{
     6[trac]
     7        env-path = /home/pakel/trac/sites/pisarnica
     8        reponame = gitrepo
     9}}}
     10
     11
     12== Napravi git hook `post-receive` unutar tog repozitorija ==
     13Unutar hooks folder se kreira datoteka `post-receive` (možda je dobro chmod a+x napraviti da se može executati)
     14
     15{{{
     16#! /bin/sh
     17# -*- coding: utf-8 -*-
     18#
     19# Copyright (C) 2014 Edgewall Software
     20#
     21# This software is licensed as described in the file COPYING, which
     22# you should have received as part of this distribution. The terms
     23# are also available at http://trac.edgewall.com/license.html.
     24#
     25# This software consists of voluntary contributions made by many
     26# individuals. For the exact contribution history, see the revision
     27# history and logs, available at http://trac.edgewall.org/.
     28#
     29# For each Git repository that has to be monitored by your Trac
     30# environment, you need to modify the hooks in order to call the
     31# present script:
     32#
     33# Configurations using git-config
     34# -------------------------------
     35# trac.env-path
     36#       Path to your Trac environment.
     37# trac.admin-path
     38#       Optional, path to trac-admin command. The default is "trac-admin".
     39# trac.reponame
     40#       Optional, repository name in your Trac environment. The default
     41#       is "(default)".
     42#
     43
     44tracenv="`git config trac.env-path`"
     45if [ -z "$tracenv" ]; then
     46    echo "trac.env-path is missing" 1>&2
     47    exit
     48fi
     49if [ ! -r "$tracenv/VERSION" ]; then
     50    echo "'$tracenv' doesn't seem to be a Trac environment" 1>&2
     51    exit
     52fi
     53tracadmin="`git config trac.admin-path`"
     54[ -z "$tracadmin" ] && tracadmin=trac-admin
     55reponame="`git config trac.reponame`"
     56[ -z "$reponame" ] && reponame='(default)'
     57log="/tmp/mylog.log"
     58
     59nullrev=0000000000000000000000000000000000000000
     60grep_args=-vF
     61changed=0
     62revlist_args=
     63while read oldrev newrev refname; do
     64    grep_args="$grep_args -e $refname"
     65    if [ $newrev != $nullrev ]; then  # branch is removed
     66        changed=1
     67        revlist_args="$revlist_args $newrev"
     68        if [ $oldrev != $nullrev ]; then  # branch is updated
     69            revlist_args="$revlist_args ^$oldrev"
     70        fi
     71    fi
     72done
     73
     74exec >>"$log" 2>&1
     75
     76if [ $changed = 0 ]; then
     77    # no new commits, but repository is changed
     78    nohup "$tracadmin" "$tracenv" repository sync "$reponame" &
     79else
     80    refnames="`
     81        git for-each-ref --format='%(refname)' refs/heads | \
     82            grep $grep_args`"
     83    for refname in $refnames; do
     84        revlist_args="$revlist_args ^$refname"
     85    done
     86    echo "[`date`] $revlist >> "$log"
     87    echo "[`date`] git rev-list --reverse $revlist_args >> "$log"
     88    echo "[`date`] \"$tracadmin\" \"$tracenv\" changeset added \"$reponame\""  >> "$log"
     89
     90    nohup $SHELL <<_EOS_ &
     91        git rev-list --reverse $revlist_args | \
     92            xargs "$tracadmin" "$tracenv" changeset added "$reponame"
     93_EOS_
     94fi
     95
     96}}}
     97
     98== Dodaj git repo kroz trac ==
     99Ukljuući podršku za git (admin plugins Trac)
     100Uključi Ticket Commit updater (admin plugins Trac)
     101 * !CommitTicketReferenceMacro
     102 * !CommitTicketUpdater