kubitron / redmine_git_hosting

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

When I register a repo that already exists in gitolite with autofetch turned off, chiliproject doesn't fetch commits. #91

Closed crocket closed 12 years ago

crocket commented 12 years ago

postgresql : 9.1.4 gitolite : 3.1.4 redmine_git_hosting : the latest master branch as of now ruby : 1.9.3

I have to push a new commit or to run "rake remine:fetch_changesets RAILS_ENV=production" to make chiliproject fetch changesets.

Is it a bug of redmine_git_hosting? or of chiliproject? Or is it a configuration problem?

kubitron commented 12 years ago

How do you know that commits have not been fetched? (what are you looking at that tells you this)?

crocket commented 12 years ago

After registering an existing repo, activity page is empty, and repository page doesn't contain any revision.

kubitron commented 12 years ago

Hm... I see. The repository has a well-defined gitolite path name based on the project name... Did you move an existing repository to that particular path and then add it to a project? Had you tried to look at the repository page for that project prior to that? Along the same lines, does this problem persist if you turn off the redmine_git_hosting cache (plugin settings page)?

What is "autofetch"? Is this a chiliProject setting? If it is the same thing as the Redmine setting called "Fetch commits automatically" from the settings page for repositories, then it seems like your system is behaving properly. According to the manual:

Fetch commits automatically:
If this option is activated, the application automatically retrieves the new revisions when a user 
consults the repository.
Default: Yes
You can disable this option and automate the call to Repository#fetch_changesets using cron to 
regularly retrieve the revisions for all of the repositories in the background.
Example:
ruby script/runner "Repository.fetch_changesets" -e production
You can also call this task from your repository in a post-commit or post-receive hook, so that 
changesets are fetched after each commit. Here is a tutorial for doing so with git: 
http://finalcog.com/remine-git-post-receive

Seems to me that you must call fetch_changesets regularly if you turn off this option (at least in Redmine). I've always had this option selected (default). Why would you disable it?

crocket commented 12 years ago

I installed gitolite and implanted some repositories. And several weeks later, I installed chiliproject and redmine_git_hosting and added the existing repositories to chiliproject.

By autofetch, I mean "Autofetch commits" option in chiliproject.

Even with "Autofetch commits" turned on, commits are not automatically fetched when an existing repository is registered to a project via redmine_git_hosting.

I disabled git cache, but the problem persists.

Since redmine_git_hosting fetches a repo automatically on commits, "Fetch commits automatically" option seems redundant. While "Fetch commits automatically:" is turned on, if someone commits and someone else visits the repository page at the same time, there may be two simultaneous fetch jobs. I think if two fetch jobs run simultaneously, database corruptions or other bugs may arise.

Perhaps, you should modify redmine_git_hosting so that it fetches commits and tags when an existing repo is registered via redmine_git_hosting.

kubitron commented 12 years ago

If you look at the end of the user manual I quoted above, redmine_git_hosting does exactly what that manual says is a valid alternative to "Fetch commits automatically" -- it uses a post-receive hook.

What enabling the "Fetch commits automatically" option really means is that your clicking on the repository link will fetch the latest commits before displaying the repository (exactly what you are complaining is not happening). You should just turn that option back on.

As for your worry about multiple fetch jobs running simultaneously and corrupting the DB, do you have evidence that this is happening? The way that the post-receive hook from redmine_git_hosting invokes the fetching of changesets is through http requests to ChiliProject. Thus, it is really up to whether the Rails framework can handle multiple requests that modify the database. In general, this works.

I'm going to close this bug, because it sounds like the behavior you are getting is because of the options you have set in ChiliProject.

crocket commented 12 years ago

Even with "Autofetch commits", when an existing repository is added to chiliproject, commits are not fetched. I'm going to make a new feature request.

kubitron commented 12 years ago

With "autofetch commits" turned on, I'm assuming that you can click on the repository link and it works? Is it only the activity page that is not updated? You should really just run the fetch_changesets option from a cron job as suggested. It will take care of this problem.

crocket commented 12 years ago

When I click the repository link, the repository and activity pages are updated.

You wrote "The way that the post-receive hook from redmine_git_hosting invokes the fetching of changesets is through http requests to ChiliProject."

Does it mean I have to check "Enable WS for repository management" in chiliproject settings?

kubitron commented 12 years ago

Yes, you enable WS for repository management, generate an API key, the use curl in your cron tab to execute a fetch changesets operation:

curl -k -o/dev/null -s https://server.name/sys/fetch_changesets?key=xxxx