diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-11-26 15:04:51 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-12-08 19:28:56 +0100 |
commit | 9f6d228d2368911befc11038d64ccb9ccae131ad (patch) | |
tree | b3d1fd35e3ca245706b5663ca479d7117dafc1f2 /app/models/project.rb | |
parent | d27de096c2d889be69b8e5ac82284bee8034d158 (diff) | |
download | gitlab-ce-9f6d228d2368911befc11038d64ccb9ccae131ad.tar.gz |
Simplify conditionals in Project#protected_ref?
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 800c8afb49f..fa1820b2bdb 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1737,10 +1737,14 @@ class Project < ActiveRecord::Base end def protected_for?(ref) - return false unless ref && !repository.ambiguous_ref?(ref) + return false if ref.nil? || repository.ambiguous_ref?(ref) resolved_ref = repository.resolve_ref(ref) - ref_name = resolved_ref == ref ? Gitlab::Git.ref_name(resolved_ref) : ref + ref_name = if resolved_ref == ref + Gitlab::Git.ref_name(resolved_ref) + else + ref + end if Gitlab::Git.branch_ref?(resolved_ref) ProtectedBranch.protected?(self, ref_name) |