- page_title "New Branch"
= render "projects/commits/header_title"

- if @error
  .alert.alert-danger
    %button{ type: "button", class: "close", "data-dismiss" => "alert"} &times;
    = @error
%h3.page-title
  New Branch
%hr

= form_tag namespace_project_branches_path, method: :post, id: "new-branch-form", class: "form-horizontal js-requires-input" do
  .form-group
    = label_tag :branch_name, nil, class: 'control-label'
    .col-sm-10
      = text_field_tag :branch_name, params[:branch_name], required: true, tabindex: 1, autofocus: true, class: 'form-control'
  .form-group
    = label_tag :ref, 'Create from', class: 'control-label'
    .col-sm-10
      = text_field_tag :ref, params[:ref] || @project.default_branch, required: true, tabindex: 2, class: 'form-control'
      .help-block Existing branch name, tag, or commit SHA
  .form-actions
    = button_tag 'Create branch', class: 'btn btn-create', tabindex: 3
    = link_to 'Cancel', namespace_project_branches_path(@project.namespace, @project), class: 'btn btn-cancel'

:javascript
  var availableRefs = #{@project.repository.ref_names.to_json};

  $("#ref").autocomplete({
    source: availableRefs,
    minLength: 1
  });
