1- merged = local_assigns.fetch(:merged, false)
2- commit = @repository.commit(branch.dereferenced_target)
3- merge_project = merge_request_source_project_for_project(@project)
4%li{ class: "branch-item js-branch-item js-branch-#{branch.name}", data: { name: branch.name } }
5  .branch-info
6    .branch-title
7      = sprite_icon('branch', size: 12, css_class: 'gl-flex-shrink-0')
8      = link_to project_tree_path(@project, branch.name), class: 'item-title str-truncated-100 ref-name gl-ml-3 qa-branch-name' do
9        = branch.name
10      - if branch.name == @repository.root_ref
11        %span.badge.gl-badge.sm.badge-pill.badge-primary.gl-ml-2 default
12      - elsif merged
13        %span.badge.gl-badge.sm.badge-pill.badge-info.has-tooltip.gl-ml-2{ title: s_('Branches|Merged into %{default_branch}') % { default_branch: @repository.root_ref } }
14          = s_('Branches|merged')
15
16      - if protected_branch?(@project, branch)
17        %span.badge.gl-badge.sm.badge-pill.badge-success.gl-ml-2
18          = s_('Branches|protected')
19
20      = render_if_exists 'projects/branches/diverged_from_upstream', branch: branch
21
22    .block-truncated
23      - if commit
24        = render 'projects/branches/commit', commit: commit, project: @project
25      - else
26        = s_('Branches|Can’t find HEAD commit for this branch')
27
28  - if branch.name != @repository.root_ref
29    .js-branch-divergence-graph
30
31  .controls.d-none.d-md-block<
32    - if commit_status
33      = render 'ci/status/icon', size: 24, status: commit_status, option_css_classes: 'gl-display-inline-flex gl-vertical-align-middle gl-mr-5'
34    - elsif show_commit_status
35      .gl-display-inline-flex.gl-vertical-align-middle.gl-mr-5
36        %svg.s24
37
38    - if merge_project && create_mr_button?(from: @repository.root_ref, to: branch.name, source_project: @project, target_project: @project)
39      = link_to create_mr_path(from: @repository.root_ref, to: branch.name, source_project: @project, target_project: @project), class: 'gl-button btn btn-default' do
40        = _('Merge request')
41
42    - if branch.name != @repository.root_ref
43      = link_to project_compare_index_path(@project, from: @repository.root_ref, to: branch.name),
44        class: "gl-button btn btn-default js-onboarding-compare-branches #{'gl-ml-3' unless merge_project}",
45        method: :post,
46        title: s_('Branches|Compare') do
47        = s_('Branches|Compare')
48
49    = render 'projects/buttons/download', project: @project, ref: branch.name, pipeline: @refs_pipelines[branch.name], class: 'gl-vertical-align-top'
50
51    - if Feature.enabled?(:delete_branch_confirmation_modals, @project, default_enabled: :yaml)
52      = render 'projects/branches/delete_branch_modal_button', project: @project, branch: branch, merged: merged
53
54    - elsif can?(current_user, :push_code, @project)
55      - if branch.name == @project.repository.root_ref
56        - delete_default_branch_tooltip = s_('Branches|The default branch cannot be deleted')
57        %span.gl-display-inline-block.has-tooltip{ title: delete_default_branch_tooltip }
58          %button{ class: 'gl-button btn btn-default btn-icon disabled', disabled: true, 'aria-label' => delete_default_branch_tooltip }
59            = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
60      - elsif protected_branch?(@project, branch)
61        - if can?(current_user, :push_to_delete_protected_branch, @project)
62          - delete_protected_branch_tooltip = s_('Branches|Delete protected branch')
63          %button{ class: 'gl-button btn btn-default btn-icon has-tooltip',
64            title: delete_protected_branch_tooltip,
65            'aria-label' => delete_protected_branch_tooltip,
66            data: { toggle: 'modal',
67              target: '#modal-delete-branch',
68              delete_path: project_branch_path(@project, branch.name),
69              branch_name: branch.name,
70              is_merged: ('true' if merged) } }
71            = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
72        - else
73          - delete_protected_branch_disabled_tooltip = s_('Branches|Only a project maintainer or owner can delete a protected branch')
74          %span.has-tooltip{ title: delete_protected_branch_disabled_tooltip }
75            %button{ class: 'gl-button btn btn-default btn-icon disabled', disabled: true, 'aria-label' => delete_protected_branch_disabled_tooltip, data: { testid: 'remove-protected-branch' } }
76              = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
77      - else
78        = link_to project_branch_path(@project, branch.name),
79          class: 'gl-button btn btn-default btn-icon js-remove-row qa-remove-btn js-ajax-loading-spinner has-tooltip',
80          title: s_('Branches|Delete branch'),
81          method: :delete,
82          data: { confirm: s_("Branches|Deleting the '%{branch_name}' branch cannot be undone. Are you sure?") % { branch_name: branch.name } },
83          remote: true,
84          'aria-label' => s_('Branches|Delete branch') do
85          = sprite_icon('remove', css_class: 'gl-button-icon gl-icon')
86