Commit 33c9f05c authored by Ciro Santilli's avatar Ciro Santilli

Append in place for strings and arrays

parent ac158424
...@@ -41,9 +41,9 @@ class Projects::RefsController < Projects::ApplicationController ...@@ -41,9 +41,9 @@ class Projects::RefsController < Projects::ApplicationController
@path = params[:path] @path = params[:path]
contents = [] contents = []
contents += tree.trees contents.push(*tree.trees)
contents += tree.blobs contents.push(*tree.blobs)
contents += tree.submodules contents.push(*tree.submodules)
@logs = contents[@offset, @limit].to_a.map do |content| @logs = contents[@offset, @limit].to_a.map do |content|
file = @path ? File.join(@path, content.name) : content.name file = @path ? File.join(@path, content.name) : content.name
......
...@@ -44,7 +44,7 @@ module CommitsHelper ...@@ -44,7 +44,7 @@ module CommitsHelper
parts = @path.split('/') parts = @path.split('/')
parts.each_with_index do |part, i| parts.each_with_index do |part, i|
crumbs += content_tag(:li) do crumbs << content_tag(:li) do
# The text is just the individual part, but the link needs all the parts before it # The text is just the individual part, but the link needs all the parts before it
link_to part, project_commits_path(@project, tree_join(@ref, parts[0..i].join('/'))) link_to part, project_commits_path(@project, tree_join(@ref, parts[0..i].join('/')))
end end
......
module GraphHelper module GraphHelper
def get_refs(repo, commit) def get_refs(repo, commit)
refs = "" refs = ""
refs += commit.ref_names(repo).join(" ") refs << commit.ref_names(repo).join(' ')
# append note count # append note count
refs += "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0 refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
refs refs
end end
......
...@@ -86,7 +86,7 @@ module ProjectsHelper ...@@ -86,7 +86,7 @@ module ProjectsHelper
def link_to_toggle_star(title, starred, signed_in) def link_to_toggle_star(title, starred, signed_in)
cls = 'star-btn' cls = 'star-btn'
cls += ' disabled' unless signed_in cls << ' disabled' unless signed_in
toggle_html = content_tag('span', class: 'toggle') do toggle_html = content_tag('span', class: 'toggle') do
toggle_text = if starred toggle_text = if starred
......
...@@ -6,7 +6,7 @@ module TagsHelper ...@@ -6,7 +6,7 @@ module TagsHelper
def tag_list(project) def tag_list(project)
html = '' html = ''
project.tag_list.each do |tag| project.tag_list.each do |tag|
html += link_to tag, tag_path(tag) html << link_to(tag, tag_path(tag))
end end
html.html_safe html.html_safe
......
...@@ -10,13 +10,16 @@ module TreeHelper ...@@ -10,13 +10,16 @@ module TreeHelper
tree = "" tree = ""
# Render folders if we have any # Render folders if we have any
tree += render partial: 'projects/tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present? tree << render(partial: 'projects/tree/tree_item', collection: folders,
locals: { type: 'folder' }) if folders.present?
# Render files if we have any # Render files if we have any
tree += render partial: 'projects/tree/blob_item', collection: files, locals: {type: 'file'} if files.present? tree << render(partial: 'projects/tree/blob_item', collection: files,
locals: { type: 'file' }) if files.present?
# Render submodules if we have any # Render submodules if we have any
tree += render partial: 'projects/tree/submodule_item', collection: submodules if submodules.present? tree << render(partial: 'projects/tree/submodule_item',
collection: submodules) if submodules.present?
tree.html_safe tree.html_safe
end end
......
...@@ -73,28 +73,28 @@ class Ability ...@@ -73,28 +73,28 @@ class Ability
# Rules based on role in project # Rules based on role in project
if team.master?(user) if team.master?(user)
rules += project_master_rules rules.push(*project_master_rules)
elsif team.developer?(user) elsif team.developer?(user)
rules += project_dev_rules rules.push(*project_dev_rules)
elsif team.reporter?(user) elsif team.reporter?(user)
rules += project_report_rules rules.push(*project_report_rules)
elsif team.guest?(user) elsif team.guest?(user)
rules += project_guest_rules rules.push(*project_guest_rules)
end end
if project.public? || project.internal? if project.public? || project.internal?
rules += public_project_rules rules.push(*public_project_rules)
end end
if project.owner == user || user.admin? if project.owner == user || user.admin?
rules += project_admin_rules rules.push(*project_admin_rules)
end end
if project.group && project.group.has_owner?(user) if project.group && project.group.has_owner?(user)
rules += project_admin_rules rules.push(*project_admin_rules)
end end
if project.archived? if project.archived?
...@@ -193,17 +193,17 @@ class Ability ...@@ -193,17 +193,17 @@ class Ability
# Only group masters and group owners can create new projects in group # Only group masters and group owners can create new projects in group
if group.has_master?(user) || group.has_owner?(user) || user.admin? if group.has_master?(user) || group.has_owner?(user) || user.admin?
rules += [ rules.push(*[
:create_projects, :create_projects,
] ])
end end
# Only group owner and administrators can manage group # Only group owner and administrators can manage group
if group.has_owner?(user) || user.admin? if group.has_owner?(user) || user.admin?
rules += [ rules.push(*[
:manage_group, :manage_group,
:manage_namespace :manage_namespace
] ])
end end
rules.flatten rules.flatten
...@@ -214,10 +214,10 @@ class Ability ...@@ -214,10 +214,10 @@ class Ability
# Only namespace owner and administrators can manage it # Only namespace owner and administrators can manage it
if namespace.owner == user || user.admin? if namespace.owner == user || user.admin?
rules += [ rules.push(*[
:create_projects, :create_projects,
:manage_namespace :manage_namespace
] ])
end end
rules.flatten rules.flatten
......
...@@ -50,7 +50,7 @@ module Mentionable ...@@ -50,7 +50,7 @@ module Mentionable
matches.each do |match| matches.each do |match|
identifier = match.delete "@" identifier = match.delete "@"
if identifier == "all" if identifier == "all"
users += project.team.members.flatten users.push(*project.team.members.flatten)
else else
id = User.find_by(username: identifier).try(:id) id = User.find_by(username: identifier).try(:id)
users << User.find(id) unless id.blank? users << User.find(id) unless id.blank?
......
...@@ -248,7 +248,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -248,7 +248,8 @@ class MergeRequest < ActiveRecord::Base
def closes_issues def closes_issues
if target_branch == project.default_branch if target_branch == project.default_branch
issues = commits.flat_map { |c| c.closes_issues(project) } issues = commits.flat_map { |c| c.closes_issues(project) }
issues += Gitlab::ClosingIssueExtractor.closed_by_message_in_project(description, project) issues.push(*Gitlab::ClosingIssueExtractor.
closed_by_message_in_project(description, project))
issues.uniq.sort_by(&:id) issues.uniq.sort_by(&:id)
else else
[] []
......
...@@ -226,7 +226,7 @@ module Network ...@@ -226,7 +226,7 @@ module Network
reserved = [] reserved = []
for day in time_range for day in time_range
reserved += @reserved[day] reserved.push(*@reserved[day])
end end
reserved.uniq! reserved.uniq!
......
...@@ -170,7 +170,7 @@ class Project < ActiveRecord::Base ...@@ -170,7 +170,7 @@ class Project < ActiveRecord::Base
def publicish(user) def publicish(user)
visibility_levels = [Project::PUBLIC] visibility_levels = [Project::PUBLIC]
visibility_levels += [Project::INTERNAL] if user visibility_levels << Project::INTERNAL if user
where(visibility_level: visibility_levels) where(visibility_level: visibility_levels)
end end
......
...@@ -160,7 +160,7 @@ class ProjectTeam ...@@ -160,7 +160,7 @@ class ProjectTeam
end end
user_ids = project_members.pluck(:user_id) user_ids = project_members.pluck(:user_id)
user_ids += group_members.pluck(:user_id) if group user_ids.push(*group_members.pluck(:user_id)) if group
User.where(id: user_ids) User.where(id: user_ids)
end end
......
...@@ -297,8 +297,8 @@ class User < ActiveRecord::Base ...@@ -297,8 +297,8 @@ class User < ActiveRecord::Base
def authorized_projects def authorized_projects
@authorized_projects ||= begin @authorized_projects ||= begin
project_ids = personal_projects.pluck(:id) project_ids = personal_projects.pluck(:id)
project_ids += groups_projects.pluck(:id) project_ids.push(*groups_projects.pluck(:id))
project_ids += projects.pluck(:id).uniq project_ids.push(*projects.pluck(:id).uniq)
Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC') Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC')
end end
end end
......
...@@ -12,11 +12,11 @@ module Gitlab ...@@ -12,11 +12,11 @@ module Gitlab
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib config.autoload_paths.push(*%W(#{config.root}/lib
#{config.root}/app/models/hooks #{config.root}/app/models/hooks
#{config.root}/app/models/concerns #{config.root}/app/models/concerns
#{config.root}/app/models/project_services #{config.root}/app/models/project_services
#{config.root}/app/models/members) #{config.root}/app/models/members))
# Only load the plugins named here, in the order given (default is alphabetical). # Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named. # :all can be used as a placeholder for all plugins not explicitly named.
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
config.encoding = "utf-8" config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password] config.filter_parameters.push(*[:password])
# Enable escaping HTML in JSON. # Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true config.active_support.escape_html_entities_in_json = true
......
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