Project

General

Profile

Feature #5386 » show_branch_tags_in_changeset_v2.diff

Minimized changes to settings.yml - Niklaus Giger, 2020-11-24 13:40

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
......
1300 1303
  label_ends_with: endet mit
1301 1304
  label_issue_fixed_version_updated: Zielversion aktualisiert
1302 1305
  setting_project_list_defaults: Voreinstellungen Projektliste
1306
  label_display_revision_branches: Zweige zur Revision anzeigen
1303 1307
  label_display_type: Ergebnisse anzeigen als
1304 1308
  label_display_type_list: Liste
1305 1309
  label_display_type_board: Karte
config/locales/en.yml
431 431
  setting_time_format: Time format
432 432
  setting_timespan_format: Time span format
433 433
  setting_cross_project_issue_relations: Allow cross-project issue relations
434
  setting_display_under_single_revision: Display revision under Single Revision
435
  setting_display_under_associated_revisions: Display revision under Associated Revisions
434 436
  setting_cross_project_subtasks: Allow cross-project subtasks
435 437
  setting_issue_list_default_columns: Isuses list defaults
436 438
  setting_repositories_encodings: Attachments and repositories encodings
......
805 807
  label_repository_plural: Repositories
806 808
  label_browse: Browse
807 809
  label_branch: Branch
810
  label_branches: Branches
808 811
  label_tag: Tag
809 812
  label_revision: Revision
810 813
  label_revision_plural: Revisions
......
932 935
  label_registration_manual_activation: manual account activation
933 936
  label_registration_automatic_activation: automatic account activation
934 937
  label_display_per_page: "Per page: %{value}"
938
  label_display_revision_branches: Show branches for revision
935 939
  label_age: Age
936 940
  label_change_properties: Change properties
937 941
  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
95 95
        rescue ScmCommandAborted
96 96
          nil
97 97
        end
98
        
99
        def branch_contains(hash)
100
          cleaned_hash = hash.sub(/[^\w]/, '')
101
          cmd_args = ['branch', '--contains', cleaned_hash]
102
          begin
103
            branches = git_cmd(cmd_args) do |io|
104
              io.readlines.sort!.map{|t| t.strip.gsub(/\* ?/, '')}
105
            end
106
          rescue ScmCommandAborted
107
            branches = Array.new
108
          end
109
          branches.uniq
110
        end
98 111

  
99 112
        def tags
100 113
          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
120 120
.breadcrumbs>.separator::before, .breadcrumbs>.separator::after {
121 121
    content: " ";
122 122
}
123

  
124
.scm-branch-group, .scm-branch-hide > .scm-branches { display: none; }
125
.scm-branch-hide > .scm-branch-group { display: inline; }
(10-10/11)