ericpaulbishop / redmine_git_hosting

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

@project.repository.tags returns StringIO object if tags are not cached #156

Open FlorianPommerening opened 12 years ago

FlorianPommerening commented 12 years ago
>> 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"]

The method tags does not return @tags explicitly, but relies on the result of the block to be returned

  scm_cmd(*cmd_args) do |io|
    @tags = io.readlines.sort!.map{|t| t.strip}
  end

Line 97 of git_adapter_patch returns the StringIO objects from scm_cmd which can lead to the StringIO to be returned from the tags method. You could either not return retio from scm_cmd or also patch tags to return @tags after the loop.

FlorianPommerening commented 12 years ago

Originally reported to Chiliproject (Link to issue)