From 44374434b5a0b4297686d5388f1124eda3adcbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 30 Nov 2018 13:07:55 +0100 Subject: Conditionally assign ref_name for more efficiency --- app/models/project.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index 0948e4625a8..79414665001 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1741,7 +1741,11 @@ class Project < ActiveRecord::Base raise Repository::AmbiguousRefError if repository.ambiguous_ref?(ref) resolved_ref = repository.expand_ref(ref) || ref - ref_name = Gitlab::Git.ref_name(resolved_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) -- cgit v1.2.1