Feature: add git tag via ui

This commit is contained in:
Dmitriy Zaporozhets 2013-07-17 14:43:18 +03:00
parent d2284b4112
commit 403638b8a0
5 changed files with 46 additions and 3 deletions

View File

@ -12,7 +12,9 @@ class Projects::TagsController < Projects::ApplicationController
end
def create
# TODO: implement
@project.repository.add_tag(params[:tag_name], params[:ref])
redirect_to project_tags_path(@project)
end
def destroy

View File

@ -41,6 +41,12 @@ class Repository
gitlab_shell.add_branch(path_with_namespace, branch_name, ref)
end
def add_tag(tag_name, ref)
Rails.cache.delete(cache_key(:tag_names))
gitlab_shell.add_tag(path_with_namespace, tag_name, ref)
end
def rm_branch(branch_name)
Rails.cache.delete(cache_key(:branch_names))

View File

@ -4,7 +4,7 @@
%i.icon-home
- if project_nav_tab? :files
= nav_link(controller: %w(tree blob blame)) do
= nav_link(controller: %w(tree blob blame edit_tree)) do
= link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref)
- if project_nav_tab? :commits

View File

@ -1,4 +1,15 @@
= render "projects/commits/head"
- if can? current_user, :push_code, @project
.pull-right
= link_to new_project_tag_path(@project), class: 'btn btn-create' do
%i.icon-add-sign
New tag
%p
Tags give ability to mark specific points in history as being important
%hr
- unless @tags.empty?
%ul.bordered-list
- @tags.each do |tag|
@ -26,7 +37,7 @@
%i.icon-download-alt
Download
- if can?(current_user, :admin_project, @project)
= 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
= 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
%i.icon-trash
= paginate @tags, theme: 'gitlab'

View File

@ -0,0 +1,24 @@
%h3.page-title
%i.icon-code-fork
New tag
= form_tag project_tags_path, method: :post do
.control-group
= label_tag :tag_name, 'Name for new tag', class: 'control-label'
.controls
= text_field_tag :tag_name, nil, placeholder: 'v3.0.1', required: true, tabindex: 1
.control-group
= label_tag :ref, 'Create from', class: 'control-label'
.controls
= text_field_tag :ref, nil, placeholder: 'master', required: true, tabindex: 2
.light Branch name or commit SHA
.form-actions
= submit_tag 'Create tag', class: 'btn btn-create', tabindex: 3
= link_to 'Cancel', project_tags_path(@project), class: 'btn btn-cancel'
:javascript
var availableTags = #{@project.repository.ref_names.to_json};
$("#ref").autocomplete({
source: availableTags,
minLength: 1
});