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
Jérome Perrin
gitlab-ce
Commits
4f71c29c
Commit
4f71c29c
authored
Apr 03, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved default_branch_protected? out of Project
parent
bf3cc824
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
13 deletions
+7
-13
app/models/project.rb
app/models/project.rb
+1
-12
app/models/protected_branch.rb
app/models/protected_branch.rb
+6
-1
No files found.
app/models/project.rb
View file @
4f71c29c
...
@@ -883,11 +883,6 @@ class Project < ActiveRecord::Base
...
@@ -883,11 +883,6 @@ class Project < ActiveRecord::Base
"
#{
url
}
.git"
"
#{
url
}
.git"
end
end
def
empty_and_default_branch_protected?
empty_repo?
&&
default_branch_protected?
end
#TODO: Check with if this is still needed, maybe because of `.select {` in ProtectedRefsMatcher
#TODO: Check with if this is still needed, maybe because of `.select {` in ProtectedRefsMatcher
#Either with tests or by asking Tim
#Either with tests or by asking Tim
def
protected_tags_array
def
protected_tags_array
...
@@ -899,7 +894,7 @@ class Project < ActiveRecord::Base
...
@@ -899,7 +894,7 @@ class Project < ActiveRecord::Base
end
end
def
user_can_push_to_empty_repo?
(
user
)
def
user_can_push_to_empty_repo?
(
user
)
!
default_branch_protected?
||
team
.
max_member_access
(
user
.
id
)
>
Gitlab
::
Access
::
DEVELOPER
!
ProtectedBranch
.
default_branch_protected?
||
team
.
max_member_access
(
user
.
id
)
>
Gitlab
::
Access
::
DEVELOPER
end
end
def
forked?
def
forked?
...
@@ -1366,12 +1361,6 @@ class Project < ActiveRecord::Base
...
@@ -1366,12 +1361,6 @@ class Project < ActiveRecord::Base
"projects/
#{
id
}
/pushes_since_gc"
"projects/
#{
id
}
/pushes_since_gc"
end
end
#TODO: Move this and methods which depend upon it
def
default_branch_protected?
current_application_settings
.
default_branch_protection
==
Gitlab
::
Access
::
PROTECTION_FULL
||
current_application_settings
.
default_branch_protection
==
Gitlab
::
Access
::
PROTECTION_DEV_CAN_MERGE
end
# Similar to the normal callbacks that hook into the life cycle of an
# Similar to the normal callbacks that hook into the life cycle of an
# Active Record object, you can also define callbacks that get triggered
# Active Record object, you can also define callbacks that get triggered
# when you add an object to an association collection. If any of these
# when you add an object to an association collection. If any of these
...
...
app/models/protected_branch.rb
View file @
4f71c29c
...
@@ -13,9 +13,14 @@ class ProtectedBranch < ActiveRecord::Base
...
@@ -13,9 +13,14 @@ class ProtectedBranch < ActiveRecord::Base
# Check if branch name is marked as protected in the system
# Check if branch name is marked as protected in the system
def
self
.
protected?
(
project
,
ref_name
)
def
self
.
protected?
(
project
,
ref_name
)
return
true
if
project
.
empty_
and_
default_branch_protected?
return
true
if
project
.
empty_
repo?
&&
default_branch_protected?
protected_refs
=
project
.
protected_branches_array
protected_refs
=
project
.
protected_branches_array
self
.
matching
(
ref_name
,
protected_refs:
protected_refs
).
present?
self
.
matching
(
ref_name
,
protected_refs:
protected_refs
).
present?
end
end
def
self
.
default_branch_protected?
current_application_settings
.
default_branch_protection
==
Gitlab
::
Access
::
PROTECTION_FULL
||
current_application_settings
.
default_branch_protection
==
Gitlab
::
Access
::
PROTECTION_DEV_CAN_MERGE
end
end
end
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