index.html.haml 2.2 KB
Newer Older
1
%h3.page-title Protected branches
2
%p.light This ability keeps stable branches secure and forces developers to use code reviews
3
%hr
4

5
.bs-callout.bs-callout-info
6
  %p Protected branches are designed to
7
  %ul
8 9 10 11
    %li prevent pushes from everybody except #{link_to "masters", help_page_path("permissions", "permissions"), class: "vlink"}
    %li prevents anyone from force pushing to the branch
    %li prevents anyone from deleting the branch
  %p Read more about #{link_to "project permissions", help_page_path("permissions", "permissions"), class: "underlined-link"}
12

13 14 15 16 17 18 19
- if can? current_user, :admin_project, @project
  = form_for [@project, @protected_branch], html: { class: 'form-horizontal' } do |f|
    -if @protected_branch.errors.any?
      .alert.alert-danger
        %ul
          - @protected_branch.errors.full_messages.each do |msg|
            %li= msg
20

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    .form-group
      = f.label :name, "Branch", class: 'control-label'
      .col-sm-10
        = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "select2"})
    .form-actions
      = f.submit 'Protect', class: "btn-create btn"
- unless @branches.empty?
  %h5 Already Protected:
  %ul.bordered-list.protected-branches-list
    - @branches.each do |branch|
      %li
        %h4
          = link_to project_commits_path(@project, branch.name) do
            %strong= branch.name
            - if @project.root_ref?(branch.name)
              %span.label.label-info default
            %span.label.label-success
S
Sullivan SENECHAL 已提交
38
              %i.fa.fa-lock
39 40 41 42 43 44 45 46 47 48 49 50
          .pull-right
            - if can? current_user, :admin_project, @project
              = link_to 'Unprotect', [@project, branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-remove btn-small"

        - if commit = branch.commit
          = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do
            = commit.short_id
          %span.light
            = gfm escape_once(truncate(commit.title, length: 40))
          #{time_ago_with_tooltip(commit.committed_date)}
        - else
          (branch was removed from repository)