trac 1.2.3 + git

55 views
Skip to first unread message

Jacques Cornily

unread,
May 25, 2019, 9:07:00 AM5/25/19
to Trac Users
Hi, 

I have a git depot, configured with
the relevant hooks in my git repositories

I can see in trac.log, an error:

GitError: Make sure the Git repository '/home/git/gtrac.git' is readable: [Errno 13] Permission denied: '/home/git/gtrac.git

This weird, as every one has read access and and access to directories.

Thus i can't see the tracbrowser, and dont get access to all my commits

Here below is the trac.log and my trac.ini

Mfg
Jacques
trac.log
trac.ini

RjOllos

unread,
May 27, 2019, 5:05:49 PM5/27/19
to Trac Users
We've seen problems like this when the parent directory is not readable by user accessing the Git repository (such as Apache user, when running Apache webserver).

Does the "git" user have access to /home? Which Linux distro are you running? Are you running tracd, or if not, which webserver?

You may want to put the repositories in a location such as /var/git.

- Ryan

J Cornily

unread,
May 28, 2019, 5:28:09 PM5/28/19
to trac-...@googlegroups.com
Hi Ryan,

Thanks of your reply and help, i did get rid off the permission error,
by having assigned the depot group ownership directory tree to apache.
My trac env is located in  /var/lib/trac/uuuu
Here is the ls -l /home/jdum/gtrac/.git/hooks  of my depot

drwxr-xr-x. 2 jdum apache 4096 28 mai   21:02 .
drwxr-xr-x. 8 jdum apache  163 28 mai   21:02 ..
-rwxr-xr-x. 1 jdum apache  452 28 mai   21:02 applypatch-msg.sample
-rwxr-xr-x. 1 jdum apache  896 28 mai   21:02 commit-msg.sample
-rwxr-xr-x. 1 jdum apache  107 28 mai   21:02 post-commit
-rwxr-xr-x. 1 jdum apache  445 28 mai   21:02 post-receive
......
# The post receive hook looks like --------------------------------------------------------------------------------
tracenv=/var/lib/trac/uuuu    # change with your Trac environment's path
repos="(default)"                   # change with your repository's name
while read oldrev newrev refname; do
    if [ "$oldrev" = 0000000000000000000000000000000000000000 ]; then
        git rev-list --reverse "$newrev" --
    else
        git rev-list --reverse "$newrev" "^$oldrev" --
    fi | xargs sudo trac-admin "$tracenv" changeset added "$repos"
done
# The post commit hook looks like ---------------------------------------------------------------------------------------
#!/bin/bash
REV=$(git rev-parse HEAD)
sudo trac-admin /var/lib/trac/uuuu changeset added "(default)"  $REV
# ------------------------------------------------------------------------------------------------------------------------------------
Here is part of the batch script i used to register my depot with trac
if [[ -r $GIT_REPO_DIR && -x $GIT_REPO_DIR  ]]
then
    cd $(dirname $GIT_REPO_DIR)

    rev=$(git rev-parse HEAD)
    sudo trac-admin "$PROJECT_DIR" changeset added "(default)" $rev && _mok "$GIT_REPO_DIR is synced with trac database"
    sudo trac-admin $PROJECT_DIR repository resync "(default)" $rev && _mok "$GIT_REPO_DIR is resynced with trac database"
    #sudo trac-admin "$PROJECT_DIR" repository alias "gtrac" "(default)" && _mok "$GIT_REPO_DIR set alias for (default)"

 
    #_mdbg 2 "Repo: $GIT_REPO_DIR is readable"
else
     _mnok "Repo is not readable"
     exit 4
fi

#------------------------------------------------------------------------------------------------------------------------------------
Attached are my trac.log file (uuuu.log)
                       my trac.ini
                       some screen shots on the trac web interface side.
Attached are some web trac interface (depot view)

Otherwise i'm using  Centos 7, and trac 1.2.3

So far, i  registered the depot with trac,
then i make some change in my depot /home/jdum/gtrac
e.g: >fff ; git add fff; git commit -m "ffff added"; git push
The post-commit hooks proceed, it appears in the log file
But in the depot  section in the web trac admin interface
There's no sign of the commit's made, and no sign of the trac browser either.

Thanks for your time and help
Mfg
Jacques



--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/trac-users/585aa074-0fbf-443e-9349-f19fc3befab8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
uuuu.log
trac.ini
sc1.png
sc3.png
sc2.png

RjOllos

unread,
Jun 4, 2019, 9:32:57 PM6/4/19
to Trac Users
I'd use this Git hook:

I noticed in the logs:
(139726099257152) Trac[uuuu:git_fs] DEBUG: disabled CachedRepository for '/home/jdum/gtrac/.git'

Please try enabling [git] cached_repository:

Then issue a resync of the command line. Hopefully the Repository Browser is showing your changes at that point, and we can go from there.

- Ryan

J Cornily

unread,
Jun 6, 2019, 6:43:51 AM6/6/19
to trac-...@googlegroups.com
Hi,

Thank you for you reply.

I enabled the cache in the git section, and it does something in the uuuu.log, 
and as you suggested, resync the depot with

sudo trac-admin /srv/uuuu repository  resync '(default)'

Bus as you can see in gui.png
I still can't see any revision for my depot '(default)'
neither trace of my commits

Mfg
Jacques



--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
trac.ini
gui.png
uuuu.log

Jun Omae

unread,
Jun 6, 2019, 7:15:13 AM6/6/19
to trac-...@googlegroups.com
Hi,

On Thu, Jun 6, 2019 at 7:43 PM 'J Cornily' via Trac Users
<trac-...@googlegroups.com> wrote:
> Thank you for you reply.
>
> I enabled the cache in the git section, and it does something in the uuuu.log,
> and as you suggested, resync the depot with
>
> sudo trac-admin /srv/uuuu repository resync '(default)'
>
> Bus as you can see in gui.png
> I still can't see any revision for my depot '(default)'
> neither trace of my commits

The following messages are logged in trac.log. It means that your web
server cannot read the git repository '/srv/gtrac/.git'.

(140259752396928) Trac[uuuu:git_fs] INFO: detected GIT version 1.8.3.1
(140259752396928) Trac[uuuu:PyGIT] DEBUG: Missing Git control file
'HEAD' in '/srv/gtrac/.git'
(140259752396928) Trac[uuuu:git_fs] ERROR: GitError: Git control files
not found in '/srv/gtrac/.git'

I suggest to make sure the git repository is readable by the web
server like this:
(www-data should be replaced with user id of your web server)

$ sudo -u www-data git --git-dir=/srv/gtrac/.git count-objects -v

--
Jun Omae <jun...@gmail.com> (大前 潤)

J Cornily

unread,
Jun 10, 2019, 8:20:44 AM6/10/19
to trac-...@googlegroups.com
Hi,
Thank you for the shift reply.
I'm having a script to configure the git core plugin.

# Initial setup

I'm using trac 1.2.3 on Centos 7
The trac instance is located under /srv/uuuu # My Project
The script basically adds the necessary settings in trac.ini
Create a bare repository in /src/gtrac.git

Install the post-commit and post-receive hooks in /srv/gtrac.git/hooks.
Clone the empty depot
And make's an initial push.
THis works as you can see the post-commit hook in action in the log


# The main problem, no commits apppear  in the repository  view----------------------------------------------------------------------------------------------------------------------

Here below is a log when i browse http://vmtrac/uuuu/admin/versioncontrol/repository

(140618003388544) Trac[uuuu:perm] DEBUG: DefaultPermissionPolicy allows admin performing EMAIL_VIEW on None
(140618003388544) Trac[uuuu:perm] DEBUG: DefaultPermissionPolicy allows admin performing WIKI_VIEW on <Resource u'wiki:WikiStart'>
(140618003388544) Trac[uuuu:perm] DEBUG: DefaultPermissionPolicy allows admin performing WIKI_VIEW on <Resource u'wiki:TracGuide'>
(140618003388544) Trac[uuuu:perm] DEBUG: DefaultPermissionPolicy allows admin performing TAGS_VIEW on None
(140618003388544) Trac[uuuu:PyGIT] DEBUG: Missing Git control file 'HEAD' in '/srv/gtrac.git'
(140618003388544) Trac[uuuu:git_fs] ERROR: GitError: Git control files not found in '/srv/gtrac.git'
(140618003388544) Trac[uuuu:main] DEBUG: Rendering response from handler
(140618003388544) Trac[uuuu:main] DEBUG: Dispatching <RequestWithSession "GET '/wikiextras/dynamicboxes.css'">
(140618003388544) Trac[uuuu:main] DEBUG: Chosen handler is <Component tracwikiextras.boxes.Boxes>
(140618003388544) Trac[uuuu:session] DEBUG: Retrieving session for ID u'admin'

It complains about the control file HEAD, despite it exists under /srv/gtrac.gitls -l /srv/gtrac.git
total 12
drwxr-xr-x. 2 jdum apache   6 10 juin  13:52 branches
-rw-r--r--. 1 jdum apache  66 10 juin  13:52 config
-rw-r--r--. 1 jdum apache  73 10 juin  13:52 description
-rw-r--r--. 1 jdum apache  23 10 juin  13:52 HEAD
drwxr-xr-x. 2 jdum apache 281 10 juin  13:52 hooks
drwxr-xr-x. 2 jdum apache  21 10 juin  13:52 info
drwxr-xr-x. 9 jdum apache  80 10 juin  13:56 objects
drwxr-xr-x. 4 jdum apache  31 10 juin  13:52 refs

# Here is the HEAD content file ----------------------------------------------------------------------------------------------------------------------
$ cat HEAD
ref: refs/heads/master
$ cat HEAD
# Regarding the result of the git command you required  ----------------------------------------------------------------------------------------------------------------------
$ cat HEAD

sudo -u apache git --git-dir=/srv/gtrac.git count-objects -v # I use /srv/gtrac.git, the depot on the server side not /srv/gtrac/.git as you asked
count: 5
size: 20
in-pack: 0
packs: 0
size-pack: 0
prune-packable: 0
garbage: 0
size-garbage: 0


Could you tell me how i get access the trac database
to check the depot database directly ?

# Here a copy of the script --------
_setGit()
{

  local aliasRepo=$0
  local defaultRepoName='(default)'

  _minf "Setup git depot on vmgit server"

  [ -d ${GIT_REPO_DIR} ] && sudo rm -rf ${GIT_REPO_DIR}

  sudo mkdir -p ${GIT_REPO_DIR} || _die "Cannot create : ${GIT_REPO_DIR}"
  sudo chown jdum:apache ${GIT_REPO_DIR}

  _mok "Created directory ${GIT_REPO_DIR}"

  cd "${GIT_REPO_DIR}";
  git init --bare || _die "Cannot create ${GIT_REPO_DIR} git bare repository"

  _minf "${GIT_REPO_DIR} is a bare repository"

  if sudo -u apache git --git-dir=${GIT_REPO_DIR} count-objects -v # What you're asking, this is working
  then
     _minf "Permissions on $GIT_DEPOT_DIR are fine"
  else
      _die "Invalid access right on $GIT_DEPOT_DIR"
  fi


  cat <<EOF > ${GIT_REPO_DIR}/hooks/post-commit
#!/bin/bash
REV=\$(git rev-parse HEAD)
sudo trac-admin ${PROJECT_DIR} changeset added "${defaultRepoName}"  \$REV
EOF

[ $? -eq 0 ] && _mok "Post commit hook in place"

cat <<EOF > ${GIT_REPO_DIR}/hooks/post-receive
#!/bin/bash
tracenv=${PROJECT_DIR}    # change with your Trac environment's path
repos="${defaultRepoName}"                   # change with your repository's name

while read oldrev newrev refname; do
    if [ "\$oldrev" = 0000000000000000000000000000000000000000 ]; then
        git rev-list --reverse "\$newrev" --
    else
        git rev-list --reverse "\$newrev" "^\$oldrev" --

    fi | xargs sudo trac-admin "\$tracenv" changeset added "\$repos"
done
EOF
[ $? -eq 0 ] && _mok "Post receive hook in place"

for hook in post-receive post-commit
do
  [ -f ${GIT_REPO_DIR}/hooks/$hook ] && chmod +rx ${GIT_REPO_DIR}/hooks/$hook
done

if [[ -r $GIT_REPO_DIR && -x $GIT_REPO_DIR  ]]
then
 # Registering the git depot within trac db
    sudo trac-admin "$PROJECT_DIR" repository add "${defaultRepoName}" ${GIT_REPO_DIR} git || _die "trac-admin repository add failed"
    _mok "repository added to $PROJECT_DIR"
    cd $GIT_REPO_DIR # 
    rev=$(git rev-parse HEAD) # The git rev-parse returns HEAD if no initial commit done
    _minf "Found rev=>$rev<"
    if [ "$rev" == "HEAD" ] # The repo is blank
    then
          cd $HOME
          [ -d $HOME/gtrac ] && sudo rm -rf $HOME/gtrac
          git clone jdum@vmtrac:${GIT_REPO_DIR}
          cd gtrac
          > F1;git add . ; git add F1; git commit -m "Initial commit F1" ; git push origin master
    fi
    rev=$(git rev-parse HEAD) # Now i got a revision
    sudo trac-admin "$PROJECT_DIR" changeset added ${defaultRepoName} $rev              || _die "trac-admin changeset added failed"
    sudo trac-admin "$PROJECT_DIR" repository resync ${defaultRepoName} $rev              || _die "trac-admin repository resync failed"
    #sudo trac-admin "$PROJECT_DIR" repository alias "${repoAlias}" ${defaultRepoName}   || _die "trac-admin repository alias failed" # Can't define an alias
else
     _die "Repo is not readable"
fi

_mdbg 1 "-- Leave _setGit"
return 0
 











--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
trac.ini
uuuu.log

Jun Omae

unread,
Jun 10, 2019, 8:48:56 AM6/10/19
to trac-...@googlegroups.com
Hi,
Are you using SELinux? If you're using SELinux, try to disable SELinux
or configure SELinux security context of the git repository.


> Could you tell me how i get access the trac database
> to check the depot database directly ?

Try to access /svr/uuuu/db/trac.db with /usr/bin/sqlite3 command if
you're using SQLite.

J Cornily

unread,
Jun 10, 2019, 9:24:44 AM6/10/19
to trac-...@googlegroups.com
Hi,
Yes selinux was on,
i try again and keep you posted

Mfg
Jacques

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.

J Cornily

unread,
Jun 10, 2019, 6:31:40 PM6/10/19
to trac-...@googlegroups.com
Hi 
Thanks a lot for your help
The guilt was an the selinux side
It would be worth therefor to update the documentation about that

Thanks again

Jacques
Reply all
Reply to author
Forward
0 new messages