Skip to content

Commit 403638b

Browse files
committed
Feature: add git tag via ui
1 parent d2284b4 commit 403638b

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

app/controllers/projects/tags_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def index
1212
end
1313

1414
def create
15-
# TODO: implement
15+
@project.repository.add_tag(params[:tag_name], params[:ref])
16+
17+
redirect_to project_tags_path(@project)
1618
end
1719

1820
def destroy

app/models/repository.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ def add_branch(branch_name, ref)
4141
gitlab_shell.add_branch(path_with_namespace, branch_name, ref)
4242
end
4343

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+
4450
def rm_branch(branch_name)
4551
Rails.cache.delete(cache_key(:branch_names))
4652

app/views/layouts/nav/_project.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%i.icon-home
55

66
- 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
88
= link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref)
99

1010
- if project_nav_tab? :commits

app/views/projects/tags/index.html.haml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
= 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+
213
- unless @tags.empty?
314
%ul.bordered-list
415
- @tags.each do |tag|
@@ -26,7 +37,7 @@
2637
%i.icon-download-alt
2738
Download
2839
- 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
3041
%i.icon-trash
3142

3243
= paginate @tags, theme: 'gitlab'

app/views/projects/tags/new.html.haml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
});

0 commit comments

Comments
 (0)