Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
695fd3cf
Commit
695fd3cf
authored
May 23, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move protected branches to Project settings
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
8ae2d215
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
109 additions
and
119 deletions
+109
-119
app/controllers/projects/branches_controller.rb
app/controllers/projects/branches_controller.rb
+3
-1
app/controllers/projects/protected_branches_controller.rb
app/controllers/projects/protected_branches_controller.rb
+2
-2
app/helpers/tab_helper.rb
app/helpers/tab_helper.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+15
-6
app/views/layouts/nav/_project.html.haml
app/views/layouts/nav/_project.html.haml
+1
-1
app/views/projects/_settings_nav.html.haml
app/views/projects/_settings_nav.html.haml
+4
-0
app/views/projects/branches/_branch.html.haml
app/views/projects/branches/_branch.html.haml
+3
-7
app/views/projects/branches/_filter.html.haml
app/views/projects/branches/_filter.html.haml
+0
-27
app/views/projects/branches/index.html.haml
app/views/projects/branches/index.html.haml
+30
-9
app/views/projects/branches/recent.html.haml
app/views/projects/branches/recent.html.haml
+0
-8
app/views/projects/commits/_head.html.haml
app/views/projects/commits/_head.html.haml
+2
-2
app/views/projects/protected_branches/index.html.haml
app/views/projects/protected_branches/index.html.haml
+47
-49
config/routes.rb
config/routes.rb
+1
-6
No files found.
app/controllers/projects/branches_controller.rb
View file @
695fd3cf
...
@@ -7,7 +7,9 @@ class Projects::BranchesController < Projects::ApplicationController
...
@@ -7,7 +7,9 @@ class Projects::BranchesController < Projects::ApplicationController
before_filter
:authorize_push!
,
only:
[
:create
,
:destroy
]
before_filter
:authorize_push!
,
only:
[
:create
,
:destroy
]
def
index
def
index
@branches
=
Kaminari
.
paginate_array
(
@repository
.
branches
).
page
(
params
[
:page
]).
per
(
30
)
@sort
=
params
[
:sort
]
||
'name'
@branches
=
@repository
.
branches_sorted_by
(
@sort
)
@branches
=
Kaminari
.
paginate_array
(
@branches
).
page
(
params
[
:page
]).
per
(
30
)
end
end
def
recent
def
recent
...
...
app/controllers/projects/protected_branches_controller.rb
View file @
695fd3cf
class
Projects::ProtectedBranchesController
<
Projects
::
ApplicationController
class
Projects::ProtectedBranchesController
<
Projects
::
ApplicationController
# Authorize
# Authorize
before_filter
:authorize_read_project!
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
before_filter
:authorize_admin_project!
before_filter
:authorize_admin_project!
,
only:
[
:destroy
,
:create
]
layout
"project_settings"
def
index
def
index
@branches
=
@project
.
protected_branches
.
to_a
@branches
=
@project
.
protected_branches
.
to_a
...
...
app/helpers/tab_helper.rb
View file @
695fd3cf
...
@@ -75,7 +75,7 @@ module TabHelper
...
@@ -75,7 +75,7 @@ module TabHelper
def
project_tab_class
def
project_tab_class
return
"active"
if
current_page?
(
controller:
"/projects"
,
action: :edit
,
id:
@project
)
return
"active"
if
current_page?
(
controller:
"/projects"
,
action: :edit
,
id:
@project
)
if
[
'services'
,
'hooks'
,
'deploy_keys'
,
'team_members'
].
include?
controller
.
controller_name
if
[
'services'
,
'hooks'
,
'deploy_keys'
,
'team_members'
,
'protected_branches'
].
include?
controller
.
controller_name
"active"
"active"
end
end
end
end
...
...
app/models/repository.rb
View file @
695fd3cf
...
@@ -55,12 +55,6 @@ class Repository
...
@@ -55,12 +55,6 @@ class Repository
tags
.
find
{
|
tag
|
tag
.
name
==
name
}
tags
.
find
{
|
tag
|
tag
.
name
==
name
}
end
end
def
recent_branches
(
limit
=
20
)
branches
.
sort
do
|
a
,
b
|
commit
(
b
.
target
).
committed_date
<=>
commit
(
a
.
target
).
committed_date
end
[
0
..
limit
]
end
def
add_branch
(
branch_name
,
ref
)
def
add_branch
(
branch_name
,
ref
)
Rails
.
cache
.
delete
(
cache_key
(
:branch_names
))
Rails
.
cache
.
delete
(
cache_key
(
:branch_names
))
...
@@ -220,4 +214,19 @@ class Repository
...
@@ -220,4 +214,19 @@ class Repository
def
clean_old_archives
def
clean_old_archives
Gitlab
::
Popen
.
popen
(
%W(find
#{
Gitlab
.
config
.
gitlab
.
repository_downloads_path
}
-mmin +120 -delete)
)
Gitlab
::
Popen
.
popen
(
%W(find
#{
Gitlab
.
config
.
gitlab
.
repository_downloads_path
}
-mmin +120 -delete)
)
end
end
def
branches_sorted_by
(
value
)
case
value
when
'recently_updated'
branches
.
sort
do
|
a
,
b
|
commit
(
b
.
target
).
committed_date
<=>
commit
(
a
.
target
).
committed_date
end
when
'last_updated'
branches
.
sort
do
|
a
,
b
|
commit
(
a
.
target
).
committed_date
<=>
commit
(
b
.
target
).
committed_date
end
else
branches
end
end
end
end
app/views/layouts/nav/_project.html.haml
View file @
695fd3cf
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
=
link_to
'Files'
,
project_tree_path
(
@project
,
@ref
||
@repository
.
root_ref
)
=
link_to
'Files'
,
project_tree_path
(
@project
,
@ref
||
@repository
.
root_ref
)
-
if
project_nav_tab?
:commits
-
if
project_nav_tab?
:commits
=
nav_link
(
controller:
%w(commit commits compare repositories
protected_branches
tags branches)
)
do
=
nav_link
(
controller:
%w(commit commits compare repositories tags branches)
)
do
=
link_to
"Commits"
,
project_commits_path
(
@project
,
@ref
||
@repository
.
root_ref
)
=
link_to
"Commits"
,
project_commits_path
(
@project
,
@ref
||
@repository
.
root_ref
)
-
if
project_nav_tab?
:network
-
if
project_nav_tab?
:network
...
...
app/views/projects/_settings_nav.html.haml
View file @
695fd3cf
...
@@ -19,3 +19,7 @@
...
@@ -19,3 +19,7 @@
=
link_to
project_services_path
(
@project
)
do
=
link_to
project_services_path
(
@project
)
do
%i
.icon-cogs
%i
.icon-cogs
Services
Services
=
nav_link
(
controller: :protected_branches
)
do
=
link_to
project_protected_branches_path
(
@project
)
do
%i
.icon-lock
Protected branches
app/views/projects/branches/_branch.html.haml
View file @
695fd3cf
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
-
if
@project
.
protected_branch?
branch
.
name
-
if
@project
.
protected_branch?
branch
.
name
%span
.label.label-success
%span
.label.label-success
%i
.icon-lock
%i
.icon-lock
protected
.pull-right
.pull-right
-
if
can?
(
current_user
,
:download_code
,
@project
)
-
if
can?
(
current_user
,
:download_code
,
@project
)
=
render
'projects/repositories/download_archive'
,
ref:
branch
.
name
,
btn_class:
'btn-grouped btn-group-small'
=
render
'projects/repositories/download_archive'
,
ref:
branch
.
name
,
btn_class:
'btn-grouped btn-group-small'
...
@@ -21,13 +22,8 @@
...
@@ -21,13 +22,8 @@
%i
.icon-trash
%i
.icon-trash
-
if
commit
-
if
commit
%p
%ul
.list-unstyled
=
link_to
project_commit_path
(
@project
,
commit
.
id
),
class:
'commit_short_id'
do
=
render
'projects/commits/inline_commit'
,
commit:
commit
,
project:
@project
=
commit
.
short_id
=
image_tag
avatar_icon
(
commit
.
author_email
),
class:
"avatar s16"
,
alt:
''
%span
.light
=
gfm
escape_once
(
truncate
(
commit
.
title
,
length:
40
))
#{
time_ago_with_tooltip
(
commit
.
committed_date
)
}
-
else
-
else
%p
%p
Cant find HEAD commit for this branch
Cant find HEAD commit for this branch
app/views/projects/branches/_filter.html.haml
deleted
100644 → 0
View file @
8ae2d215
%ul
.nav.nav-pills.nav-stacked
=
nav_link
(
path:
'branches#recent'
)
do
=
link_to
recent_project_branches_path
(
@project
)
do
Recent
.pull-right
=
@repository
.
recent_branches
.
count
=
nav_link
(
path:
'protected_branches#index'
)
do
=
link_to
project_protected_branches_path
(
@project
)
do
Protected
%i
.icon-lock
.pull-right
=
@project
.
protected_branches
.
count
=
nav_link
(
path:
'branches#index'
)
do
=
link_to
project_branches_path
(
@project
)
do
All branches
.pull-right
=
@repository
.
branch_names
.
count
%hr
-
if
can?
current_user
,
:push_code
,
@project
=
link_to
new_project_branch_path
(
@project
),
class:
'btn btn-create'
do
%i
.icon-add-sign
New branch
app/views/projects/branches/index.html.haml
View file @
695fd3cf
=
render
"projects/commits/head"
=
render
"projects/commits/head"
.row
%h3
.page-title
.col-md-3
Branches
=
render
"filter"
.pull-right
.col-md-9
-
if
can?
current_user
,
:push_code
,
@project
-
unless
@branches
.
empty?
=
link_to
new_project_branch_path
(
@project
),
class:
'btn btn-create'
do
%i
.icon-add-sign
New branch
.dropdown.inline
%a
.dropdown-toggle.btn
{
href:
'#'
,
"data-toggle"
=>
"dropdown"
}
%span
.light
sort:
-
if
@sort
.
present?
=
@sort
.
humanize
-
else
Name
%b
.caret
%ul
.dropdown-menu
%li
=
link_to
project_branches_path
(
sort:
nil
)
do
Name
=
link_to
project_branches_path
(
sort:
'recently_updated'
)
do
Recently updated
=
link_to
project_branches_path
(
sort:
'last_updated'
)
do
Last updated
%hr
-
unless
@branches
.
empty?
%ul
.bordered-list.top-list.all-branches
%ul
.bordered-list.top-list.all-branches
-
@branches
.
each
do
|
branch
|
-
@branches
.
each
do
|
branch
|
=
render
"projects/branches/branch"
,
branch:
branch
=
render
"projects/branches/branch"
,
branch:
branch
...
...
app/views/projects/branches/recent.html.haml
deleted
100644 → 0
View file @
8ae2d215
=
render
"projects/commits/head"
.row
.col-md-3
=
render
"filter"
.col-md-9
%ul
.bordered-list.top-list
-
@branches
.
each
do
|
branch
|
=
render
"projects/branches/branch"
,
branch:
branch
app/views/projects/commits/_head.html.haml
View file @
695fd3cf
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
=
link_to
'Compare'
,
project_compare_index_path
(
@project
,
from:
@repository
.
root_ref
,
to:
@ref
||
@repository
.
root_ref
)
=
link_to
'Compare'
,
project_compare_index_path
(
@project
,
from:
@repository
.
root_ref
,
to:
@ref
||
@repository
.
root_ref
)
=
nav_link
(
html_options:
{
class:
branches_tab_class
})
do
=
nav_link
(
html_options:
{
class:
branches_tab_class
})
do
=
link_to
recent_
project_branches_path
(
@project
)
do
=
link_to
project_branches_path
(
@project
)
do
Branches
Branches
%span
.badge
=
@repository
.
branches
.
length
%span
.badge
=
@repository
.
branches
.
size
=
nav_link
(
controller: :tags
)
do
=
nav_link
(
controller: :tags
)
do
=
link_to
project_tags_path
(
@project
)
do
=
link_to
project_tags_path
(
@project
)
do
...
...
app/views/projects/protected_branches/index.html.haml
View file @
695fd3cf
=
render
"projects/commits/head"
%h3
.page-title
Protected branches
.row
%p
.light
This ability allows to keep stable branches secured and force code review before merge to protected branches
.col-md-3
%hr
=
render
"projects/branches/filter"
.col-md-9
.bs-callout.bs-callout-info
.bs-callout.bs-callout-info
%p
Protected branches designed to
%p
Protected branches designed to
%ul
%ul
%li
prevent push for all except
#{
link_to
"masters"
,
help_permissions_path
,
class:
"vlink"
}
.
%li
prevent push for all except
#{
link_to
"masters"
,
help_permissions_path
,
class:
"vlink"
}
.
%li
prevent branch from force push
%li
prevent branch from force push
%li
prevent branch from removal
%li
prevent branch from removal
%p
This ability allows to keep stable branches secured and force code review before merge to protected branches
%p
Read more about project permissions
#{
link_to
"here"
,
help_permissions_path
,
class:
"underlined-link"
}
%p
Read more about project permissions
#{
link_to
"here"
,
help_permissions_path
,
class:
"underlined-link"
}
-
if
can?
current_user
,
:admin_project
,
@project
-
if
can?
current_user
,
:admin_project
,
@project
=
form_for
[
@project
,
@protected_branch
],
html:
{
class:
'form-horizontal'
}
do
|
f
|
=
form_for
[
@project
,
@protected_branch
],
html:
{
class:
'form-horizontal'
}
do
|
f
|
-
if
@protected_branch
.
errors
.
any?
-
if
@protected_branch
.
errors
.
any?
.alert.alert-danger
.alert.alert-danger
...
@@ -26,7 +24,7 @@
...
@@ -26,7 +24,7 @@
=
f
.
select
(
:name
,
@project
.
open_branches
.
map
{
|
br
|
[
br
.
name
,
br
.
name
]
}
,
{
include_blank:
"Select branch"
},
{
class:
"select2"
})
=
f
.
select
(
:name
,
@project
.
open_branches
.
map
{
|
br
|
[
br
.
name
,
br
.
name
]
}
,
{
include_blank:
"Select branch"
},
{
class:
"select2"
})
.form-actions
.form-actions
=
f
.
submit
'Protect'
,
class:
"btn-create btn"
=
f
.
submit
'Protect'
,
class:
"btn-create btn"
-
unless
@branches
.
empty?
-
unless
@branches
.
empty?
%h5
Already Protected:
%h5
Already Protected:
%ul
.bordered-list.protected-branches-list
%ul
.bordered-list.protected-branches-list
-
@branches
.
each
do
|
branch
|
-
@branches
.
each
do
|
branch
|
...
...
config/routes.rb
View file @
695fd3cf
...
@@ -243,12 +243,7 @@ Gitlab::Application.routes.draw do
...
@@ -243,12 +243,7 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
do
resources
:branches
,
only:
[
:index
,
:new
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
collection
do
get
:recent
,
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
end
end
resources
:tags
,
only:
[
:index
,
:new
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
resources
:tags
,
only:
[
:index
,
:new
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
resources
:protected_branches
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
resources
:protected_branches
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
Gitlab
::
Regex
.
git_reference_regex
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment