Commit d7eee733 authored by Michael Kozono's avatar Michael Kozono

Extract and memoize `user_access`

Because it is sometimes never used.
parent 0e3cfc75
......@@ -22,18 +22,13 @@ module Gitlab
PUSH_COMMANDS = %w{ git-receive-pack }.freeze
ALL_COMMANDS = DOWNLOAD_COMMANDS + PUSH_COMMANDS
attr_reader :actor, :project, :protocol, :user_access, :authentication_abilities
attr_reader :actor, :project, :protocol, :authentication_abilities
def initialize(actor, project, protocol, authentication_abilities:)
@actor = actor
@project = project
@protocol = protocol
@authentication_abilities = authentication_abilities
@user_access = if ci?
CiAccess.new
else
UserAccess.new(user, project: project)
end
end
def check(cmd, changes)
......@@ -244,5 +239,13 @@ module Gitlab
nil
end
end
def user_access
@user_access ||= if ci?
CiAccess.new
else
UserAccess.new(user, project: project)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment