Project

General

Profile

Feature #5386 » 5386-tags-in-associated-revisions-2.3-stable.diff

Patch to add list of tags to associated revisions for redmine 2.3 - Evzen Sindelar, 2013-06-05 18:19

View differences:

app/models/repository/git.rb Thu May 30 15:36:29 2013 +0200
210 210
        # that it's not in the db.
211 211
        save_revision(rev)
212 212
        save_revision_branches(rev)
213
        save_revision_tags(rev)
213 214
      end
214 215
    end
215 216
    h["heads"] = repo_heads.dup
......
218 219
  end
219 220
  private :save_revisions
220 221

  
222
  def save_revision_tags(rev)
223
    db_rev = find_changeset_by_name(rev.scmid)
224
    unless db_rev.nil?
225
      tags = scm.revision_tags(rev.scmid)
226
      unless tags.nil?
227
        db_rev.tags = tags.join(',')
228
        db_rev.save
229
      end
230
    end
231
  end
232
  private :save_revision_tags
233

  
221 234
  def save_revision_branches(rev)
222 235
    db_rev = find_changeset_by_name(rev.scmid)
223 236
    unless db_rev.nil?
......
230 243
  end
231 244
  private :save_revision_branches
232 245

  
246
  
233 247
  def save_revision(rev)
234 248
    parents = (rev.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact
235 249
    changeset = Changeset.create(
app/views/issues/_changesets.html.erb Thu May 30 15:36:29 2013 +0200
10 10
            </span>
11 11
        <% end %>
12 12
        <br />
13

  
13
        <% if changeset.tags? %>
14
            <span style="float: right;">
15
            <%== changeset.tags.split(',').collect{ |tag|
16
            changeset.repository.tags.include?(tag) ? 
17
              tag : nil }.compact.join(' / ') %>
18
            </span>
19
        <% end %>
20
        <br />
14 21
        <span class="author"><%= authoring(changeset.committed_on, changeset.author) %></span></p>
15 22
    <div class="wiki">
16 23
        <%= textilizable(changeset, :comments) %>
db/migrate/20130530152055_add_changesets_tags.rb Thu May 30 15:36:29 2013 +0200
1
class AddChangesetsTags < ActiveRecord::Migration
2
  def self.up
3
    add_column :changesets, :tags, :string, :limit => nil, :default => nil
4
  end
5

  
6
  def self.down
7
    remove_column :changesets, :tags
8
  end
9
end
lib/redmine/scm/adapters/git_adapter.rb Thu May 30 15:36:29 2013 +0200
325 325
          nil
326 326
        end
327 327

  
328
        def revision_tags(identifier)
329
          cmd_args = %w|tag -l --contains|
330
          cmd_args << identifier
331
          tags = []
332
          git_cmd(cmd_args) do |io|
333
            io.each_line do |line|
334
              tags << line.match('(.*)$')[1]
335
            end
336
          end
337
          tags.sort!
338
        rescue ScmCommandAborted
339
          nil
340
        end
341
        
328 342
        def diff(path, identifier_from, identifier_to=nil)
329 343
          path ||= ''
330 344
          cmd_args = []
(6-6/11)