Project

General

Profile

Feature #5386 » 0001-5386-Branch-Tags-in-Changeset-Description-4.2.patch

Show branches/tags in redmine 4.2 - Niklaus Giger, 2022-11-14 12:51

View differences:

app/helpers/repositories_helper.rb
326 326
    end
327 327
    max_space
328 328
  end
329

  
330
  def has_branch_detail?
331
    @repository.scm.respond_to? :branch_contains
332
  end
333

  
334
  def insert_branches_detail(html)
335
    return html unless has_branch_detail?
336
    substring = '</li>'
337
    location = html.index(substring).to_i + substring.length
338
    html.insert(location, branches_html)
339
  end
340

  
341
  def branches_html
342
    content_tag(:li) do
343
      content = content_tag(:strong, "#{l(:label_branch)}")
344
      content << " "
345
      content << "#{@repository.identifier}@ "
346
      content << links_to_branches.join(', ').html_safe
347
    end
348
  end
349

  
350
  def links_to_branches
351
    return [] unless has_branch_detail?
352
    branch_groups.map { |name, branches| branches_link(name, branches) }
353
  end
354

  
355
  def branches_link(name, branches)
356
    return branch_link(branches.first) if branches.length == 1
357
    link =  link_to("[#{name}...]", 'javascript:;', class: 'scm-branch-group').html_safe
358
    content_tag(:span, class: 'scm-branch-hide') do
359
      link << content_tag(:span, class: 'scm-branches') do
360
        branches.map { |branch| branch_link(branch) }.join(', ').html_safe
361
      end
362
    end
363
  end
364

  
365
  def branch_link(branch)
366
    link_to(branch, {:controller => 'repositories',
367
                     :action => 'show',
368
                     :id => @repository.project,
369
                     :repository_id => @repository.identifier,
370
                     :path => to_path_param(@path),
371
                     :rev => branch}).html_safe
372
  end
373

  
374
  def branch_groups
375
    @repository.scm.branch_contains(@rev).group_by do |branch|
376
      branch.downcase
377
        .gsub(/^\d+/, '#####')
378
        .split(/[\-\._]/)
379
        .first
380
    end.sort_by { |name, branches| [branches.length, name] }
381
  end
382

  
383

  
329 384
end
app/views/issues/tabs/_changesets.html.erb
14 14
           :repository_id => changeset.repository.identifier_param,
15 15
           :path   => "",
16 16
           :rev    => changeset.identifier) %>)
17
      <% if !Setting.display_under_associated_revisions? && changeset.scmid.present?
18
           @repository = changeset.repository
19
           @rev = changeset.identifier
20
      %>
21
         (<em><%= l(:label_branches) %>: <%= links_to_branches.join(', ').html_safe %></em>)
22
      <% end %>
17 23
    <% end %></p>
18 24

  
19 25
    <div class="wiki changeset-comments">
app/views/repositories/_changeset.html.erb
20 20
              }.join(", ").html_safe %>
21 21
      </li>
22 22
    <% end %>
23
      <% if !Setting.display_under_single_revision? %>
24
      <li>
25
        <strong><%= l(:label_branches) %></strong>
26
        <%=  links_to_branches.join(', ').html_safe %>
27
      </li>
28
      <% end %>
29

  
23 30
    <% if @changeset.children.present? %>
24 31
      <li>
25 32
        <strong><%= l(:label_child_revision) %></strong>
app/views/settings/_issues.html.erb
24 24
<p><%= setting_text_field :gantt_items_limit, :size => 6 %></p>
25 25

  
26 26
<p><%= setting_text_field :gantt_months_limit, :size => 6 %></p>
27

  
27 28
</div>
29
<fieldset class="box">
30
  <legend><%= l(:label_display_revision_branches) %></legend>
31
  <div class="tabular settings">
32
<p><%= setting_check_box :display_under_single_revision %></p>
33

  
34
<p><%= setting_check_box :display_under_associated_revisions %></p>
35
  </div>
36
</fieldset>
28 37

  
29 38
<fieldset class="box">
30 39
  <legend><%= l(:label_parent_task_attributes) %></legend>
config/locales/de.yml
460 460
  label_board_sticky: Wichtig (immer oben)
461 461
  label_boolean: Boolean
462 462
  label_branch: Zweig
463
  label_branches: Zweige
463 464
  label_browse: Codebrowser
464 465
  label_bulk_edit_selected_issues: Alle ausgewählten Tickets bearbeiten
465 466
  label_bulk_edit_selected_time_entries: Ausgewählte Zeitaufwände bearbeiten
......
1004 1005
  setting_default_projects_tracker_ids: Standardmäßig aktivierte Tracker für neue Projekte
1005 1006
  setting_diff_max_lines_displayed: Maximale Anzahl anzuzeigender Diff-Zeilen
1006 1007
  setting_display_subprojects_issues: Tickets von Unterprojekten im Hauptprojekt anzeigen
1008
  setting_display_under_single_revision: Unterschiede bei Revision anzeigen
1009
  setting_display_under_associated_revisions: Bei zugehörigen Revisionen anzeigen
1007 1010
  setting_emails_footer: E-Mail-Fußzeile
1008 1011
  setting_emails_header: E-Mail-Kopfzeile
1009 1012
  setting_enabled_scm: Aktivierte Versionskontrollsysteme
......
1299 1302
  label_ends_with: endet mit
1300 1303
  label_issue_fixed_version_updated: Zielversion aktualisiert
1301 1304
  setting_project_list_defaults: Voreinstellungen Projektliste
1305
  label_display_revision_branches: Zweige zur Revision anzeigen
1302 1306
  label_display_type: Ergebnisse anzeigen als
1303 1307
  label_display_type_list: Liste
1304 1308
  label_display_type_board: Karte
config/locales/en.yml
434 434
  setting_time_format: Time format
435 435
  setting_timespan_format: Time span format
436 436
  setting_cross_project_issue_relations: Allow cross-project issue relations
437
  setting_display_under_single_revision: Display revision under Single Revision
438
  setting_display_under_associated_revisions: Display revision under Associated Revisions
437 439
  setting_cross_project_subtasks: Allow cross-project subtasks
438 440
  setting_issue_list_default_columns: Issues list defaults
439 441
  setting_repositories_encodings: Attachments and repositories encodings
......
811 813
  label_repository_plural: Repositories
812 814
  label_browse: Browse
813 815
  label_branch: Branch
816
  label_branches: Branches
814 817
  label_tag: Tag
815 818
  label_revision: Revision
816 819
  label_revision_plural: Revisions
......
938 941
  label_registration_manual_activation: manual account activation
939 942
  label_registration_automatic_activation: automatic account activation
940 943
  label_display_per_page: "Per page: %{value}"
944
  label_display_revision_branches: Show branches for revision
941 945
  label_age: Age
942 946
  label_change_properties: Change properties
943 947
  label_general: General
config/settings.yml
226 226
issue_list_default_totals:
227 227
  serialized: true
228 228
  default: []
229
display_under_single_revision:
230
  default: true
231
display_under_associated_revisions:
232
  default: true
229 233
display_subprojects_issues:
230 234
  default: 1
231 235
time_entry_list_defaults:
lib/redmine/scm/adapters/git_adapter.rb
98 98
        rescue ScmCommandAborted
99 99
          nil
100 100
        end
101
        
102
        def branch_contains(hash)
103
          cleaned_hash = hash.sub(/[^\w]/, '')
104
          cmd_args = ['branch', '--contains', cleaned_hash]
105
          begin
106
            branches = git_cmd(cmd_args) do |io|
107
              io.readlines.sort!.map{|t| t.strip.gsub(/\* ?/, '')}
108
            end
109
          rescue ScmCommandAborted
110
            branches = Array.new
111
          end
112
          branches.uniq
113
        end
101 114

  
102 115
        def tags
103 116
          return @tags if @tags
public/javascripts/repository_navigation.js
33 33
      $('#branch,#tag').removeAttr('disabled');
34 34
    }
35 35
  });
36

  
37
  $('a.scm-branch-group').on('click', function() {
38
    $(this).parent().removeClass('scm-branch-hide');
39
  });
36 40
})
public/stylesheets/scm.css
117 117
div.action_D { background: #f88 }
118 118
div.action_A { background: #bfb }
119 119

  
120
.scm-branch-group, .scm-branch-hide > .scm-branches { display: none; }
121
.scm-branch-hide > .scm-branch-group { display: inline; }
122

  
120 123
.breadcrumbs>.separator::before, .breadcrumbs>.separator::after {
121 124
    content: " ";
122 125
}
(11-11/11)