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
f51eac1d
Commit
f51eac1d
authored
Mar 17, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Settings::RepositoryController includes protected tags in JS
parent
91ed8ed6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
23 deletions
+40
-23
app/controllers/projects/settings/repository_controller.rb
app/controllers/projects/settings/repository_controller.rb
+23
-7
app/models/concerns/protected_ref_access.rb
app/models/concerns/protected_ref_access.rb
+16
-16
app/models/project.rb
app/models/project.rb
+1
-0
No files found.
app/controllers/projects/settings/repository_controller.rb
View file @
f51eac1d
...
...
@@ -7,22 +7,23 @@ module Projects
@deploy_keys
=
DeployKeysPresenter
.
new
(
@project
,
current_user:
current_user
)
define_protected_
branche
s
define_protected_
ref
s
end
private
def
define_protected_branches
load_protected_branches
def
define_protected_refs
@protected_branches
=
@project
.
protected_branches
.
order
(
:name
).
page
(
params
[
:page
])
@protected_tags
=
@project
.
protected_tags
.
order
(
:name
).
page
(
params
[
:page
])
@protected_branch
=
@project
.
protected_branches
.
new
@protected_tag
=
@project
.
protected_tags
.
new
load_gon_index
end
def
load_protected_branches
@protected_branches
=
@project
.
protected_branches
.
order
(
:name
).
page
(
params
[
:page
])
end
def
access_levels_options
#TODO: consider protected tags
#TODO: Refactor ProtectedBranch::PushAccessLevel so it doesn't mention branches
{
push_access_levels:
{
roles:
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
map
do
|
id
,
text
|
...
...
@@ -37,13 +38,28 @@ module Projects
}
end
#TODO: Move to Protections::TagMatcher.new(project).unprotected
def
unprotected_tags
exact_protected_tag_names
=
@project
.
protected_tags
.
reject
(
&
:wildcard?
).
map
(
&
:name
)
tag_names
=
@project
.
repository
.
tags
.
map
(
&
:name
)
non_open_tag_names
=
Set
.
new
(
exact_protected_tag_names
).
intersection
(
Set
.
new
(
tag_names
))
@project
.
repository
.
tags
.
reject
{
|
tag
|
non_open_tag_names
.
include?
tag
.
name
}
end
def
unprotected_tags_hash
tags
=
unprotected_tags
.
map
{
|
tag
|
{
text:
tag
.
name
,
id:
tag
.
name
,
title:
tag
.
name
}
}
{
open_tags:
tags
}
end
def
open_branches
branches
=
@project
.
open_branches
.
map
{
|
br
|
{
text:
br
.
name
,
id:
br
.
name
,
title:
br
.
name
}
}
{
open_branches:
branches
}
end
def
load_gon_index
gon
.
push
(
open_branches
.
merge
(
access_levels_options
))
gon
.
push
(
open_branches
)
gon
.
push
(
unprotected_tags_hash
)
gon
.
push
(
access_levels_options
)
end
end
end
...
...
app/models/concerns/protected_ref_access.rb
View file @
f51eac1d
module
ProtectedBranch
Access
extend
ActiveSupport
::
Concern
# module ProtectedRef
Access
#
extend ActiveSupport::Concern
included
do
belongs_to
:protected_branch
delegate
:project
,
to: :protected_branch
#
included do
# #
belongs_to :protected_branch
# #
delegate :project, to: :protected_branch
scope
:master
,
->
{
where
(
access_level:
Gitlab
::
Access
::
MASTER
)
}
scope
:developer
,
->
{
where
(
access_level:
Gitlab
::
Access
::
DEVELOPER
)
}
end
#
scope :master, -> { where(access_level: Gitlab::Access::MASTER) }
#
scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
#
end
def
humanize
self
.
class
.
human_access_levels
[
self
.
access_level
]
end
#
def humanize
#
self.class.human_access_levels[self.access_level]
#
end
def
check_access
(
user
)
return
true
if
user
.
is_admin?
#
def check_access(user)
#
return true if user.is_admin?
project
.
team
.
max_member_access
(
user
.
id
)
>=
access_level
end
end
#
project.team.max_member_access(user.id) >= access_level
#
end
#
end
app/models/project.rb
View file @
f51eac1d
...
...
@@ -866,6 +866,7 @@ class Project < ActiveRecord::Base
end
# Branches that are not _exactly_ matched by a protected branch.
#TODO: Move to Protections::BranchMatcher.new(project).unprotecte
def
open_branches
exact_protected_branch_names
=
protected_branches
.
reject
(
&
:wildcard?
).
map
(
&
:name
)
branch_names
=
repository
.
branches
.
map
(
&
:name
)
...
...
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