Project

General

Profile

Defect #13036 » cs.patch

Fix repo identifier in commit link - A B, 2013-03-17 06:51

View differences:

app/models/changeset.rb 2013-03-14 16:30:16.639922046 -0700
153 153
  end
154 154

  
155 155
  def text_tag(ref_project=nil)
156
    tag = if scmid?
157
      "commit:#{scmid}"
156
    repo_id = if (repository && repository.identifier.present?)
157
      "#{repository.identifier}|"
158 158
    else
159
      "r#{revision}"
159
      ""
160 160
    end
161
    if repository && repository.identifier.present?
162
      tag = "#{repository.identifier}|#{tag}"
161
    tag = if scmid?
162
      "commit:#{repo_id}#{scmid}"
163
    else
164
      "#{repo_id}r#{revision}"
163 165
    end
164 166
    if ref_project && project && ref_project != project
165 167
      tag = "#{project.identifier}:#{tag}"
166
-- test/unit/changeset_test.rb.orig	2013-03-14 16:30:10.003824745 -0700
168
++ test/unit/changeset_test.rb	2013-03-16 22:44:42.898105363 -0700
......
286 286
    assert_equal 'commit:0123456789', c.text_tag
287 287
  end
288 288

  
289
  def test_text_tag_hash_with_repository_identifier
290
    r = Repository::Git.create!(
291
          :project_id => 1,
292
          :url     => 'git://localhost/test',
293
          :identifier => 'documents')
294
    
295
    c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => r)
296
    assert_equal 'commit:documents|7234cb27', c.text_tag
297
    assert_equal 'ecookbook:commit:documents|7234cb27', c.text_tag(Project.find(2))
298
  end
299

  
289 300
  def test_previous
290 301
    changeset = Changeset.find_by_revision('3')
291 302
    assert_equal Changeset.find_by_revision('2'), changeset.previous
(1-1/2)