ericpaulbishop / redmine_git_hosting

A ChiliProject/Redmine plugin which makes configuring your own git hosting easy.
185 stars 37 forks source link

Redmine Repository page is not updating correctly. #89

Open vky opened 13 years ago

vky commented 13 years ago

A project's Repository page does not seem able to track the project's repository. The repository itself seems to working fine, multiple users are able to push and pull from the repository, just the web view of the repository seems to be broken. This is what it looks like:

VM that has Redmine with redmine_git_plugin installed: http://i.imgur.com/8P7tE.png VM that has Redmine without redmine_git_plugin: http://i.imgur.com/8NEg0.png

The Redmine server is the WEBrick server that comes with Redmine, I've installed the plugin according to the instructions given, and gitolite was installed following this installation example under a user named 'gitolite'.

I'm using the following: Redhat Enterprise Linux 5 Redmine v1.2 Redmine_git_hosting v0.4.1

I'm not particularly familiar with Redmine, Ruby or Linux to figure out what might be going wrong here, and I didn't see any previous issues that were similar to this problem. Any help with this would be greatly appreciated, thank you.

ericpaulbishop commented 13 years ago

This was a compatibility issue with Redmine Trunk. This should be fixed now, in the latest version (0.4.2), released today.

vky commented 12 years ago

I've updated to version 0.4.2, and this problem still exists. I've tested with a clean install of Redmine as well, problem seems to still exist. Could it be something I'm doing in the installation process, or something else?

ghost commented 12 years ago

Try to enable the Redmine "Report last commit for files and directories" option. Many times, this option doesn't get enabled. By the way, make sure that your permissions are correct and whatnot. Your post-receive hook may not be working correctly (you can also check this in the plugin configuration panel).

ericpaulbishop commented 12 years ago

Can you specify which svn revision of redmine you're using, specifically? I tested with latest trunk, and 1.2.1, it's possible there's somewhere in between where there is still a problem (or, there was a still newer commit than when I last tested and it broke again). Since I could replicate the problem, but only with redmine trunk (which I then fixed), I really need to know exactly what version you're working on before I can do any more to try to address this.

ghost commented 12 years ago

Is it possible this is related to my issue #80? I have Redmine Trunk, and one of the things I noticed was that when the mirrors didn't push was when the repository didn't update, although it always seems to update correctly for master. I'm on revision 7401.

vky commented 12 years ago

I'm using 'Redmine 1.2.1.stable.7482 (MySQL)'. I obtained it with "svn co http://redmine.rubyforge.org/svn/branches/1.2-stable redmine-1.2".

'Autofetch commits' option is checked in the Administration > Repository page, if Roejames12's suggestion of enabling "Report last commit for files and directories" refers to the option mentioned here, http://www.redmine.org/issues/8365, I do not see that option anywhere.

As far as the plugin configuration panel, everything looks good as far as I can tell (http://i.imgur.com/6Amdb.png). What permissions might I be overlooking? What can I check for to see if the post-receive hook, or any hook, isn't functioning properly?

I don't know if this will be of any use, but here is the log immediately after creating a new project:

Processing ProjectsController#new (for 127.0.0.1 at 2011-09-28 08:44:00) [GET] Parameters: {"action"=>"new", "controller"=>"projects"} Rendering template within layouts/base Rendering projects/new Completed in 95ms (View: 46, DB: 31) | 200 OK [http://localhost/projects/new] remote: Counting objects: 22, done. remote: Compressing objects: 100% (17/17), done. remote: Total 22 (delta 3), reused 0 (delta 0) Receiving objects: 100% (22/22), done. Resolving deltas: 100% (3/3), done. Counting objects: 7, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 358 bytes, done. Total 4 (delta 1), reused 0 (delta 0) remote: remote: remote: Repository does not have "hooks.redmine_gitolite.key" set. Skipping hook. remote: remote: remote: creating blah2... remote: Initialized empty Git repository in /home/gitolite/repositories/blah2.git/ To gitolite@localhost:gitolite-admin.git e8b2d7f..948c5b1 master -> master

Processing ProjectsController#create (for 127.0.0.1 at 2011-09-28 08:44:07) [POST] Parameters: {"commit"=>"Save", "action"=>"create", "authenticity_token"=>"JxF9b3nL9BRO5lH47FzHpwvYATsVrXJkHzAYtM3wrxw=", "project"=>{"name"=>"blah 2", "tracker_ids"=>["1", "2", "3", ""], "homepage"=>"", "parent_id"=>"", "is_public"=>"1", "description"=>"", "identifier"=>"blah2", "enabled_module_names"=>["issue_tracking", "time_tracking", "news", "documents", "files", "wiki", > "repository", "boards", "calendar", "gantt", ""]}, "controller"=>"projects"} Redirected to http://localhost:3000/projects/blah2/settings Cloning gitolite-admin repository Our hook is already installed Our hook is already installed Setting up hooks for project blah2 Completed in 11922ms (DB: 278) | 302 Found [http://localhost/projects]

Processing ProjectsController#settings (for 127.0.0.1 at 2011-09-28 08:44:19) [GET] Parameters: {"action"=>"settings", "id"=>"blah2", "controller"=>"projects"} Rendering template within layouts/base Rendering projects/settings DEPRECATION WARNING: @repository will no longer be implicitly assigned to repository. (called from _run_rhtml_vendor47plugins47redmine_git_hosting47app47views47projects47settings47_repository46rhtml_locals_object_repository_tab at /home/vk/redmine-1.2/vendor/plugins/redmine_git_hosting/app/views/projects/settings/_repository.rhtml:56) DEPRECATION WARNING: @repository will no longer be implicitly assigned to repository. (called from _run_rhtml_vendor47plugins47redmine_git_hosting47app47views47projects47settings47_repository46rhtml_locals_object_repository_tab at /home/vk/redmine-1.2/vendor/plugins/redmine_git_hosting/app/views/projects/settings/_repository.rhtml:56) DEPRECATION WARNING: @repository will no longer be implicitly assigned to repository. (called from _run_rhtml_vendor47plugins47redmine_git_hosting47app47views47projects47settings47_repository46rhtml_locals_object_repository_tab at /home/vk/redmine-1.2/vendor/plugins/redmine_git_hosting/app/views/projects/settings/_repository.rhtml:56) DEPRECATION WARNING: @repository will no longer be implicitly assigned to repository. (called from _run_rhtml_vendor47plugins47redmine_git_hosting47app47views47projects47settings47_repository46rhtml_locals_object_repository_tab at /home/vk/redmine-1.2/vendor/plugins/redmine_git_hosting/app/views/projects/settings/_repository.rhtml:109) Completed in 654ms (View: 594, DB: 43) | 200 OK [http://localhost/projects/blah2/settings] fatal: Not a valid object name HEAD:

ericpaulbishop commented 12 years ago

I tested with this svn revision of redmine, but I still haven't been able to reproduce your error. I figured out what was going on with the deprecation warnings you see in the log above (and fixed it), but that has nothing to do with repository display...

vky commented 12 years ago

Additional info, hopefully of some use:

Is there anyway that I can log what's occurring when Redmine or the plugin checks for new commits, or should be receiving a message of a new commit?

Some unrelated questions (not sure if these should be issues of their own):

ericpaulbishop commented 12 years ago

Ah....

_For the '/tmp/redmine_git_hosting/run_git_as_gituser', I've found it necessary to change "git $cmd" to "/usr/local/bin/git$cmd". Whenever an change is made in the plugin configuration panel, this change gets reverted. Is there a proper way to set this up that I missed?

That means git isn't in your PATH. Fix the problem with your environment PATH variable and try again.

bleleve commented 12 years ago

Hi there,

First of all, thank you Eric for this great module ;)

I have exactly the same issue as discribe here, I can only see the first commit in the Redmine repository panel.

I have Redmine 1.2.1.stable (MySQL) and Redmine Git Hosting Plugin (v0.4.2). My PATH seems to be OK.

Best regards, Benoît.

vky commented 12 years ago

Curious stuff. I found a way to make the Repository & Activity pages work, sort of. It seems that this problem revolves around the Max Cache Time parameter in the Git Cache Parameters section of the plugin configuration page. If it is set to 'until next commit', well, nothing seems to work. But if it's changed to '1 minute or until next commit', the Repository page will work.

Sort of. Or at least not how I expected it to work. I was expecting Redmine/the plugin to automatically detect new pushes, but that doesn't seem to be the case. I have to specifically refresh the Repository page of each individual project for any changes to show up in the Activity stream.

My initial test project for this was a single text file, that noted what I did each commit. I suppose I viewed the text file on the 3rd commit, when I tested the Max Cache Time toggling hypothesis, and did not attempt to view it until the 10th commit. But before I viewed the file a second time, I had changed Max Cache Time back to 'until next commit', and the file had not updated itself. Toggling back to '1 minute or until next commit', and going back to view the file, the file then updated to the current version.

When refreshing the Repository page, it takes a noticeable amount of time. between 6 and 10 seconds. I may add an edit to this on Monday, I think there's a minor detail or two I might be leaving out. Anyhow, these were the major findings of the day, hope it helps.

ericpaulbishop commented 12 years ago

vkorapaty: it's not "Curious stuff." I told you, fix your PATH variable.

Git isn't in your path, so the code tries to access your repo, and can't because it can't access git. Then you go in and fix the code so that the exact path is in /tmp/redmine_git_hosting. But the wrong value is still cached... so when you edit it it doesn't fix the problem, but if you let the cache expire it starts working.

So... fix your PATH variables. Then try again.

bleleve: What tests have you performed to ensure that your path is ok? How do you know you don't have the same problem as vkorapaty?

bleleve commented 12 years ago

git is in /usr/bin and this directory is in the root's PATH and the www-data's PATH too (Rails is loaded with the www-data user).

www-data@----:~$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games www-data@----:~$ git --help usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [-c name=value] [--help] COMMAND [ARGS]

ericpaulbishop commented 12 years ago

I'm still not convinced. Just because it's there when change to that user on the shell, doesn't mean it's accessible in rails/redmine. I just added a section in the plugin settings page to help debug path problems. Either install the latest repo code, or add the following code to app/views/settings/_redmine_git_hosting.html.erb:

<p>
    <label>PATH Directories</label>
    <%= (ENV['PATH']).gsub(/:/, "<br/>") %>
    <br/>
</p>

Then let me know what the PATH Directories section shows in admin=>plugins=>redmine git hosting section of the web interface.

vky commented 12 years ago

Git is installed to /usr/local/bin. I had edited the PATH to include that directory on both the Redmine and Gitolite users before starting the testing I did on Saturday. I did not have to edit the /tmp/redmine_git_hosting/run_git_as_git_user file, unlike before.

Added the code to the file and this is the result:

/usr/kerberos/bin /usr/local/bin /usr/bin /bin /usr/X11R6/bin /home/vk/bin

Redmine is installed under the user 'vk', and Gitolite is installed under the user 'gitolite'.

bleleve commented 12 years ago

Here is the result :

PATH Directories /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /var/lib/gems/1.8/bin

ericpaulbishop commented 12 years ago

Ok, you've convinced me it's not a PATH issue. Try running the following command as the redmine user, and let me know what the output is:

/tmp/redmine_git_hosting/run_git_as_git_user --git-dir="repositories/blah2.git" --work-tree="repositories/blah2.git" branch --no-color

This assumes you have a repository with id "blah2", as listed above by vkorapaty. If you have a repo named something else, substitute that in for blah2 above.

bleleve commented 12 years ago

The output is : www-data@----:~$ /tmp/redmine_git_hosting/run_git_as_git_user --git-dir="repositories/myrepo.git" --work-tree="repositories/myrepo.git" branch --no-color

ericpaulbishop commented 12 years ago

Hmm.. that's the expected output, and it means you can run git just fine to access the repo. Which means whatever is going on is probably fairly subtle.

I'm going to try a couple more things to try to reproduce the problem. If I can actually get a system where this is happening I might be able to better figure out what's going on/ what's causing it.

vky commented 12 years ago

[vk@localhost redmine-1.2]$ /tmp/redmine_git_hosting/run_git_as_git_user --git-dir="repositories/test.git" --work-tree="repositories/test.git" branch --no-color

  • master

If it would help, I can upload a copy of the VMWare Player image I'm using, and instructions of the installation route I took. It would be a fairly large upload (4-6 gigs), so it might take a bit to get put up.

ericpaulbishop commented 12 years ago

That would be very helpful, though you're going to have to find somewhere to upload it to -- I don't have anywhere with that much space available.

ericpaulbishop commented 12 years ago

To clarify -- I don't have anywhere in the cloud with that much space currently available. I can download/test if you can specify somewhere I can download the image from.

JimmyAx commented 12 years ago

I also have this issue. Live demo at https://dev.usoog.com/projects/viral-shift/repository (Yes the certificate is invalid)

Redmine 1.2.1 Redmine Git Hosting Plugin 0.4.2

cota commented 12 years ago

Same issue here, the initial push (of an existing repo) went fine, but then subsequent pushes do not show up in the Repository page. When I access it, /var/log/httpd/error_log shows this the first time:

NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /home/chili/.rvm/gems/ree-1.8.7-2011.03/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21.
/home/chili/chiliproject/lib/redmine/scm/adapters/git_adapter.rb:21: warning: already initialized constant SCM_GIT_REPORT_LAST_COMMIT
/home/chili/chiliproject/lib/redmine/scm/adapters/git_adapter.rb:24: warning: already initialized constant GIT_BIN

And this every time after that:

 fatal: Invalid object name '04'.

I use Chiliproject on CentOS 5.7 with Apache + mod_passenger. I got the plugin from git a few minutes ago.

btw Eric I can give you temporary access to this machine, it's not in production at all. Contact me privately for details. Thanks!

cota commented 12 years ago

More info: git version 1.7.4, Ruby 1.8.7. I've tried with Ruby 1.9.2, but it doesn't help.

This message I see in httpd's (Apache) error log

fatal: Invalid object name '04'.

seems related, since it comes from git. Any easy way to debug all calls to git? Printing those to a logfile would be best. Thanks!

mattkaar commented 12 years ago

I'm seeing this issue as well. Comments and commits are missing from the Repository view, although the file tree displays properly otherwise.

Ubuntu 10.04.03 LTS Redmine 1.2.2 Redmine Git Hosting Plugin 0.4.2

A quick look at /var/log/apache2/error.log and /usr/local/redmine/log/production.log doesn't show anything out of the ordinary.

mercury00 commented 12 years ago

I'm just posting to say I'm seeing this too. Also, when creating blah2, I also got the message about 'remote: Repository does not have "hooks.redmine_gitolite.key" set. Skipping hook.' - is this important?

mattkaar commented 12 years ago

I was able to fix my problem by temporarily changing Max Cache Time to "1 minute or until next commit". After the cache was built, I changed that setting back to "until next commit" and things have been working fine since.

bitprokleins commented 12 years ago

Same issue here. Changing the Max Cache Time only helps for one commit. After a commit the incommings only available when I click on repository tab. The push in hook debug returns:

$ git push
Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 500 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: 
remote: 
remote: Repository does not have "hooks.redmine_gitolite.key" set. Skipping hook.
remote: 
remote: 
To git@git.myserver.com:wwwproject.git
   0abc00b..d42cb8d  master -> master

Is there a way to fix it? Thank you.

bitprokleins commented 12 years ago

I have a part of the solution. The problem was, that i have pushed a repository which not initialized by redmine. So, if you just have this problem, go, remove the remote repository in git (also in the file system), enable create repository for new project, check it out and add your sources to the repository, than push.

bloeper commented 12 years ago

Is there already a fix for this problem? I have the same problem.... this command: /tmp/redmine_git_hosting/run_git_as_git_user --git-dir="repositories/blah2.git" --work-tree="repositories/blah2.git" branch --no-color Also gives the expected output. The thingy with max-cache works for me also 1 time.

bitprokleins commented 12 years ago

I've fixed this problem. Make sure in Redmine -> Administration -> Plugins -> redmine_git_hosting contains the domain name of your redmine in HTTP Server Domain (for git http urls). I believe Redmine and Git with smart HTTP have to be available on the same Domain for this Plugin. I just use SSH, so I don't need smart HTTP. I fixed this problem bei inserting the Redmine Domain in that field, because gitolight trys to call the URL entered in this field via HTTP. I hope this helps.

bloeper commented 12 years ago

Hmm tried it, but doesn't seem to make a difference here

tomka commented 12 years ago

@bloeper: Does your redmine instance run on HTTP and/or HTTPS? The post-receive hook of the redmine_git_hosting plugin first tests if it can connect with HTTPS to redmine. If that fails it uses HTTP. On a testing instance I set up only HTTP and HTTPS was redirected. Unfortunately, this redirect wasn't recognized by the redmine_git_hosting plugin as a failure and updates got never pushed to redmine. After having set up HTTPS, too, it worked. So make sure you either support HTTPS (which is more secure) or make sure noting is reached over HTTPS with your redmine URL.

Also, like bitprokleins, in the beginning I got the same error as he got in the Dec. 20th post (hooks.redmine_gitolite.key). I had a project which did not initialize with redmine, but just attached the repo to it. This caused a problem as this key-variable was not set in the repo (look in repo dir/config). Unfortunately, again like bitprokleins, I found no other way than rebuilding the repo through redmine.

jehoshua02 commented 12 years ago

I had an issue with git not seeing ruby on the path because I installed ruby under chili with rvm. I solved the issue by symlinking chili's ruby under /usr/local/bin, which is in the git user's path.

The post-receive hook needs ruby in order to expire the cache files for the repository viewer.

https://github.com/ericpaulbishop/redmine_git_hosting/issues/150

JimmyAx commented 12 years ago

Could be worth having a look at the issue above if you are having problems.

EspadaV8 commented 12 years ago

As with other people I've found that changing the cache time to "1 minute or next commit" has 'fixed' the issue. It's far from ideal since anyone accessing the page now has to wait for the repo to be checked for updates even it there weren't any.

I've not received any messages back while pushing and I had set the URL in the setting from the start (although only SSH is used). I've not found anything of relevance in /var/log nor could I find anything in production.log.

deflomu commented 12 years ago

To get some more messages from gitolite you can disable the async option of this plugin. The normal output of a git push should then look like this:

$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 273 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: 
remote: 
remote: 
remote: Notifying ChiliProject/Redmine project testproject12345 about changes to this repo...
remote: Fetching changesets for testproject's repository ... Done
remote: Success
remote: 
remote: 
remote: 
remote: 
To git@example.com:testproject12345.git
   06aa502..f84536f  master -> master

On my server that revealed that chiliproject was not reachable from localhost. I tested this with the command curl http://example.com/chiliproject/githooks/post-receive. Try this from remote and from localhost (your server). This should return No project was found with the identifier "". If it returns something else, there is a problem with your server configuration. On my server it returned

<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="http://net.net/error/example">here</a>.</body>

I found out that the DNS server I was using returned the wrong IP. (Try curl -v to get the IP). After fixing this the update worked with the cache setting set to "until next commit" for more than one time.

Maybe this helps someone.

jamilan commented 11 years ago

I manage to fix the repos not initialized from red mine by editing their config files on the server and adding the following lines to the <pathname>/config file.

[hooks "redmine_gitolite"]
    key = <key>
    projectid = <repo>

Where , and are the columns from the following query

SELECT p.identifier, r.url, g.key
FROM  `git_repository_extras` g,  `repositories` r,  `projects` p
WHERE g.id = r.id
AND r.project_id = p.id

Run the query on the redmine or chiliproject database. (Tested on chiliproject)

Hope it helps!

kwisatz commented 11 years ago

I do also have the

remote: Repository does not have "hooks.redmine_gitolite.key" set. Skipping hook.

issue. Keys seem to be generated for automatically created projects, but not for projects created from within a projects settings tab. Oh, I should probably mention that his is in version 0.6.1 and that there's no key in the DB for that project either, so that jamilan's workaround wouldn't work unless one was to manually update the row with a key. The version of redmine we're using is 1.4.4