Commit 403638b8a00735632c060ab32cc0c1a64937b935

Authored by Dmitriy Zaporozhets
1 parent d2284b41

Feature: add git tag via ui

app/controllers/projects/tags_controller.rb
... ... @@ -12,7 +12,9 @@ class Projects::TagsController < Projects::ApplicationController
12 12 end
13 13  
14 14 def create
15   - # TODO: implement
  15 + @project.repository.add_tag(params[:tag_name], params[:ref])
  16 +
  17 + redirect_to project_tags_path(@project)
16 18 end
17 19  
18 20 def destroy
... ...
app/models/repository.rb
... ... @@ -41,6 +41,12 @@ class Repository
41 41 gitlab_shell.add_branch(path_with_namespace, branch_name, ref)
42 42 end
43 43  
  44 + def add_tag(tag_name, ref)
  45 + Rails.cache.delete(cache_key(:tag_names))
  46 +
  47 + gitlab_shell.add_tag(path_with_namespace, tag_name, ref)
  48 + end
  49 +
44 50 def rm_branch(branch_name)
45 51 Rails.cache.delete(cache_key(:branch_names))
46 52  
... ...
app/views/layouts/nav/_project.html.haml
... ... @@ -4,7 +4,7 @@
4 4 %i.icon-home
5 5  
6 6 - if project_nav_tab? :files
7   - = nav_link(controller: %w(tree blob blame)) do
  7 + = nav_link(controller: %w(tree blob blame edit_tree)) do
8 8 = link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref)
9 9  
10 10 - if project_nav_tab? :commits
... ...
app/views/projects/tags/index.html.haml
1 1 = render "projects/commits/head"
  2 +
  3 +- if can? current_user, :push_code, @project
  4 + .pull-right
  5 + = link_to new_project_tag_path(@project), class: 'btn btn-create' do
  6 + %i.icon-add-sign
  7 + New tag
  8 +
  9 +%p
  10 + Tags give ability to mark specific points in history as being important
  11 +%hr
  12 +
2 13 - unless @tags.empty?
3 14 %ul.bordered-list
4 15 - @tags.each do |tag|
... ... @@ -26,7 +37,7 @@
26 37 %i.icon-download-alt
27 38 Download
28 39 - if can?(current_user, :admin_project, @project)
29   - = link_to project_tag_path(@project, tag.name), class: 'btn grouped btn-small remove-row', method: :delete, confirm: 'Removed tag cannot be restored. Are you sure?', remote: true do
  40 + = link_to project_tag_path(@project, tag.name), class: 'btn btn-small remove-row', method: :delete, confirm: 'Removed tag cannot be restored. Are you sure?', remote: true do
30 41 %i.icon-trash
31 42  
32 43 = paginate @tags, theme: 'gitlab'
... ...
app/views/projects/tags/new.html.haml 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +%h3.page-title
  2 + %i.icon-code-fork
  3 + New tag
  4 += form_tag project_tags_path, method: :post do
  5 + .control-group
  6 + = label_tag :tag_name, 'Name for new tag', class: 'control-label'
  7 + .controls
  8 + = text_field_tag :tag_name, nil, placeholder: 'v3.0.1', required: true, tabindex: 1
  9 + .control-group
  10 + = label_tag :ref, 'Create from', class: 'control-label'
  11 + .controls
  12 + = text_field_tag :ref, nil, placeholder: 'master', required: true, tabindex: 2
  13 + .light Branch name or commit SHA
  14 + .form-actions
  15 + = submit_tag 'Create tag', class: 'btn btn-create', tabindex: 3
  16 + = link_to 'Cancel', project_tags_path(@project), class: 'btn btn-cancel'
  17 +
  18 +:javascript
  19 + var availableTags = #{@project.repository.ref_names.to_json};
  20 +
  21 + $("#ref").autocomplete({
  22 + source: availableTags,
  23 + minLength: 1
  24 + });
... ...