ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
@project.repository.tags returns StringIO object if tags are not cached (Bug #934)
Description
This happens in git repositories with the redmine gitolite plugin installed, but looking at the code, I guess it could happen with git repositories in general.
>> p = Project.find("myproject") => #<Project id: 300, name: "myproject", description: "", homepage: "", is_public: false, parent_id: 285, created_on: "2012-02-27 13:51:22", updated_on: "2012-02-27 13:51:22", identifier: "myproject", status: 1, lft: 493, rgt: 494> >> r = p.repository => #<Repository::Git id: 310, project_id: 300, url: "repositories/myproject.git", login: "", password: "", root_url: "repositories/myproject.git", type: "Repository::Git", path_encoding: nil, log_encoding: nil> >> t = r.tags => #<StringIO:0xb5384d60> >> t.eof? => true >> t = r.tags => ["deletethistag", "deletethistag2"]
One easy fix is to change
scm_cmd(*cmd_args) do |io| @tags = io.readlines.sort!.map{|t| t.strip} end
into
scm_cmd(*cmd_args) do |io| @tags = io.readlines.sort!.map{|t| t.strip} end @tags
in the method tags of GitAdapter.
History
Updated by Felix Schäfer at 2012-03-20 09:18 pm
Hello Florian,
Would you be able to write a test for this?
Updated by Florian Pommerening at 2012-03-21 09:31 am
Hello Felix,
I'm new to Ruby/Rails and I'm not sure how to write a test. I looked at the existing tests and saw test/unit/repository_git_test.rb It looks like this uses a repository that already contains tags (well, at least one). I guess the following lines added to this file would be enough:
def test_tags tags = @repository.tags assert_equal [ 'tag01.annotated', ], tags end
However, due to the caching, this test would only fail if it is the first time the method tags is called. If tags was called on the same repository before, it will return the correct result cached in its @tags instance variable.
Updated by Felix Schäfer at 2012-03-21 07:10 pm
I can't reproduce that:
>> r = Project.first.repository => #<Repository::Git id: 1, project_id: 1, url: "/Users/felix/Code/tmp/grack/.git", login: "", password: "", root_url: "/Users/felix/Code/tmp/grack/.git", type: "Repository::Git", path_encoding: "", log_encoding: nil> >> r.tags => ["v0.1", "v0.2"]
Can you confirm this is a problem on a vanilla installation too or if it's only if you have the gitolite plugin installed?
Updated by Felix Schäfer at 2012-03-21 07:10 pm
- Status changed from Open to Needs more information
Updated by Florian Pommerening at 2012-03-22 09:32 am
I'm sorry, I cannot test on a vanilla instance right now. Maybe it has something to do with the ruby version (1.8.7)? Could be related to this bug in ruby
- Status changed from Needs more information to Ready for review
Updated by Felix Schäfer at 2012-03-22 10:59 am
(Please don't set the status of this to "Ready for review" until the scope and causes of this have been fully studied, thanks)
I couldn't reproduce this on ruby 1.8.7 (2011-06-30 patchlevel 352), so it's not related to any "recent" version of 1.8.7 (the linked bug is 4 years old…), what exact version of ruby are you on?
- Status changed from Ready for review to Needs more information
Updated by Florian Pommerening at 2012-03-22 12:05 pm
>> ruby -v ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
So its probably not the ruby version :-)
I just did another test and the issue doesn't occur with our development instance (which doesn't use the gitolite plugin and is set to the environment "development"). It still happens with our live system, though (gitolite plugin and set to the "production" rails environment). Unfortunately, I cannot test whether it is the production environment or the gitolite plugin that makes the difference.
Another guess:
vendor/plugins/redmine_git_hosting/lib/git_hosting/patches/git_adapter_patch.rb line 97 returns the io object which seems to me like it could cause this issue (keep in mind that I'm just starting out with ruby, so this is really just a guess)
Updated by Felix Schäfer at 2012-03-22 04:11 pm
Florian Pommerening wrote:
Another guess:
vendor/plugins/redmine_git_hosting/lib/git_hosting/patches/git_adapter_patch.rb line 97 returns the io object which seems to me like it could cause this issue (keep in mind that I'm just starting out with ruby, so this is really just a guess)
This looks like a plugin, if you give me a link to the source I can have a look.
Updated by Florian Pommerening at 2012-03-22 06:44 pm
Yes, this is the gitolite plugin I was talking about. Sorry, I should have mentioned that from the start. Here is the line of code I mentioned
Updated by Felix Schäfer at 2012-03-22 08:05 pm
This looks like the plugin is the culprit. Unless you can confirm this also happens on ChiliProject without the plugin, I'll have to decline this issue and ask you to contact the plugin author.
Updated by Florian Pommerening at 2012-03-23 10:32 am
Ok, I'll do that. Thanks for your help.
Updated by Florian Pommerening at 2012-03-23 10:54 am
For posterity's sake here is link to the created issue
Updated by Felix Schäfer at 2012-03-23 10:58 am
Closing here, thanks a lot for the feedback.
- Status changed from Needs more information to Declined