| | 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 == |
| | 13 | Unutar 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 | |
| | 44 | tracenv="`git config trac.env-path`" |
| | 45 | if [ -z "$tracenv" ]; then |
| | 46 | echo "trac.env-path is missing" 1>&2 |
| | 47 | exit |
| | 48 | fi |
| | 49 | if [ ! -r "$tracenv/VERSION" ]; then |
| | 50 | echo "'$tracenv' doesn't seem to be a Trac environment" 1>&2 |
| | 51 | exit |
| | 52 | fi |
| | 53 | tracadmin="`git config trac.admin-path`" |
| | 54 | [ -z "$tracadmin" ] && tracadmin=trac-admin |
| | 55 | reponame="`git config trac.reponame`" |
| | 56 | [ -z "$reponame" ] && reponame='(default)' |
| | 57 | log="/tmp/mylog.log" |
| | 58 | |
| | 59 | nullrev=0000000000000000000000000000000000000000 |
| | 60 | grep_args=-vF |
| | 61 | changed=0 |
| | 62 | revlist_args= |
| | 63 | while 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 |
| | 72 | done |
| | 73 | |
| | 74 | exec >>"$log" 2>&1 |
| | 75 | |
| | 76 | if [ $changed = 0 ]; then |
| | 77 | # no new commits, but repository is changed |
| | 78 | nohup "$tracadmin" "$tracenv" repository sync "$reponame" & |
| | 79 | else |
| | 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_ |
| | 94 | fi |
| | 95 | |
| | 96 | }}} |
| | 97 | |
| | 98 | == Dodaj git repo kroz trac == |
| | 99 | Ukljuući podršku za git (admin plugins Trac) |
| | 100 | Uključi Ticket Commit updater (admin plugins Trac) |
| | 101 | * !CommitTicketReferenceMacro |
| | 102 | * !CommitTicketUpdater |