Help browsing Git repository from Redmine

Added by Rodrigo Tassinari over 9 years ago

Hello everyone,

I am evaluating Redmine to be used at my company, since we are switching from Subversion + Trac to Git + (probably) Redmine.

Everything is working fine, except browsing the files on the repositories. It just won't show anything.

I suspect that it has something to do with the repositories being "bare" Git repositories. We are using Gitosis (http://eagain.net/gitweb/?p=gitosis.git;a=blob;f=README.rst) to manage our central repositories, in the same server as the Redmine install, and Gitosis works only with bare repositories (as far as I can tell). Tracking the commits and showing diffs works fine though.

Is this correct? Is this a bug in Redming or am I doing something wrong?

Thanks a lot,
Rodrigo.

Replies (10)

RE: Help browsing Git repository from Redmine - Added by Thomas Lecavelier over 9 years ago

Could you provide the string you're using to indicate path to your git repository, please?

RE: Help browsing Git repository from Redmine - Added by Rodrigo Tassinari over 9 years ago

Sure, it's /var/git/repositories/store.git

/var/git is the $HOME for the "git" pseudo-user. The "repositories" dir is created by gitosis, where it keeps all the repos dirs. The contents of the /var/git/repositories/store.git are what usually you'll find in a git bare repos, like objects, hooks, refs, etc.

I contacted the author of gitosis ('Tv' on #git @ irc.freenode.net), he said that gitosis currently only works with bare repos, but he browsed quickly trough redmine's source code and he thinks redmine's using the wrong commands to browse the source code of the repos, but couldn't look into that right now.

RE: Help browsing Git repository from Redmine - Added by Thomas Lecavelier over 9 years ago

I think too, but maybe (depending famous french rail strikes ;)) I'll have time for it this evening or tomorrow. I love so much git and gitosis that I'll try to give redmine a better git handling. Thank you for your informations.

RE: Help browsing Git repository from Redmine - Added by Marcos Piccinini over 9 years ago

Rodrigo, you got a permission problem there.
Check who is the user running redmine server, and grant read permissions to it on the repo.

RE: Help browsing Git repository from Redmine - Added by Rodrigo Tassinari over 9 years ago

Marcos, I don't think it's a permission problem.

The git repositories are owned by the user 'git' and group 'git', and the rails processes are started by the user 'deploy' (via Passenger / mod_rails). But the repositories have read permission to all users. And even when starting redmine via mongrel by the root user, the problem remains.

I even did a "@sudo chmod -R +r /var/git/repositories/*" just to be sure, to no effect.

RE: Help browsing Git repository from Redmine - Added by Tiago Bortoletto Vaz over 9 years ago

Hey guys, I have the same here. Actually it's not e permission problem. I'll try to take a look at the git browser source, but I guess it would take a long time to I feel myself able to hack. Anyway, do you have any news about this issue?

RE: Help browsing Git repository from Redmine - Added by Rodrigo Tassinari over 9 years ago

Hi Tiago and everyone,

I still haven't figured out how to change the git browser in Redmine, but I do have found a workaround, as described in a comment by "Stu" in this blog post : you can create a post-update hook on your git bare repos, that will do a git pull of the same repos to a previously created checkout copy on the same server, and point redmine to that full repos instead.

It works fine for new projects, but since Redmine doesn't allow me to change the repository, my old projects still don't have source code browsing.

RE: Help browsing Git repository from Redmine - Added by Tiago Bortoletto Vaz over 9 years ago

Hi,

Thanks for your answer. In my case the problem is a conflict with rails version. The truncate(...) method called by the Redmine's git browser (repositories/_dir_list_content.rhtml) is not compatible with the my actionpack-2.0.2. The workaround here is just replace the truncate method in:

/var/lib/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/text_helper.rb

I just replaced the truncate method by this one (which is from a previous version):

def truncate(text, length = 30, truncate_string = "...")
if text.nil? then return end
l = length - truncate_string.length
if $KCODE == "NONE"
text.length > length ? text[0...l] + truncate_string : text
else
chars = text.split(//)
chars.length > length ? chars[0...l].join + truncate_string : text
end
end

...then restarting apache and it works perfectly. I'm using last Redmine 0.7 branch. For trunk releases there is no conflicts between rails 2.0.2 and Redmine.

ps: IMO it's a bad hack since I may have trouble updating rails in the future, but it's ok for now :)

RE: Help browsing Git repository from Redmine - Added by Tiago Bortoletto Vaz over 9 years ago

Just formating the source above. Inline sources here seems not to work very well...

def truncate(text, length = 30, truncate_string = "...")
        if text.nil? then return end
        l = length - truncate_string.length
        if $KCODE == "NONE" 
          text.length > length ? text[0...l] + truncate_string : text
        else
          chars = text.split(//)
          chars.length > length ? chars[0...l].join + truncate_string : text
        end
      end

(1-10/10)