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
@path = params[:path]
contents = []
contents += tree.trees
contents += tree.blobs
contents += tree.submodules
contents.push(*tree.trees)
contents.push(*tree.blobs)
contents.push(*tree.submodules)
@logs = contents[@offset, @limit].to_a.map do |content|
file = @path ? File.join(@path, content.name) : content.name
......
......@@ -44,7 +44,7 @@ module CommitsHelper
parts = @path.split('/')
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
link_to part, project_commits_path(@project, tree_join(@ref, parts[0..i].join('/')))
end
......
module GraphHelper
def get_refs(repo, commit)
refs = ""
refs += commit.ref_names(repo).join(" ")
refs << commit.ref_names(repo).join(' ')
# 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
end
......
......@@ -86,7 +86,7 @@ module ProjectsHelper
def link_to_toggle_star(title, starred, signed_in)
cls = 'star-btn'
cls += ' disabled' unless signed_in
cls << ' disabled' unless signed_in
toggle_html = content_tag('span', class: 'toggle') do
toggle_text = if starred
......
......@@ -6,7 +6,7 @@ module TagsHelper
def tag_list(project)
html = ''
project.tag_list.each do |tag|
html += link_to tag, tag_path(tag)
html << link_to(tag, tag_path(tag))
end
html.html_safe
......
......@@ -10,13 +10,16 @@ module TreeHelper
tree = ""
# 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
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
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
end
......
......@@ -73,28 +73,28 @@ class Ability
# Rules based on role in project
if team.master?(user)
rules += project_master_rules
rules.push(*project_master_rules)
elsif team.developer?(user)
rules += project_dev_rules
rules.push(*project_dev_rules)
elsif team.reporter?(user)
rules += project_report_rules
rules.push(*project_report_rules)
elsif team.guest?(user)
rules += project_guest_rules
rules.push(*project_guest_rules)
end
if project.public? || project.internal?
rules += public_project_rules
rules.push(*public_project_rules)
end
if project.owner == user || user.admin?
rules += project_admin_rules
rules.push(*project_admin_rules)
end
if project.group && project.group.has_owner?(user)
rules += project_admin_rules
rules.push(*project_admin_rules)
end
if project.archived?
......@@ -193,17 +193,17 @@ class Ability
# Only group masters and group owners can create new projects in group
if group.has_master?(user) || group.has_owner?(user) || user.admin?
rules += [
rules.push(*[
:create_projects,
]
])
end
# Only group owner and administrators can manage group
if group.has_owner?(user) || user.admin?
rules += [
rules.push(*[
:manage_group,
:manage_namespace
]
])
end
rules.flatten
......@@ -214,10 +214,10 @@ class Ability
# Only namespace owner and administrators can manage it
if namespace.owner == user || user.admin?
rules += [
rules.push(*[
:create_projects,
:manage_namespace
]
])
end
rules.flatten
......
......@@ -50,7 +50,7 @@ module Mentionable
matches.each do |match|
identifier = match.delete "@"
if identifier == "all"
users += project.team.members.flatten
users.push(*project.team.members.flatten)
else
id = User.find_by(username: identifier).try(:id)
users << User.find(id) unless id.blank?
......
......@@ -248,7 +248,8 @@ class MergeRequest < ActiveRecord::Base
def closes_issues
if target_branch == project.default_branch
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)
else
[]
......
......@@ -226,7 +226,7 @@ module Network
reserved = []
for day in time_range
reserved += @reserved[day]
reserved.push(*@reserved[day])
end
reserved.uniq!
......
......@@ -170,7 +170,7 @@ class Project < ActiveRecord::Base
def publicish(user)
visibility_levels = [Project::PUBLIC]
visibility_levels += [Project::INTERNAL] if user
visibility_levels << Project::INTERNAL if user
where(visibility_level: visibility_levels)
end
......
......@@ -160,7 +160,7 @@ class ProjectTeam
end
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)
end
......
......@@ -297,8 +297,8 @@ class User < ActiveRecord::Base
def authorized_projects
@authorized_projects ||= begin
project_ids = personal_projects.pluck(:id)
project_ids += groups_projects.pluck(:id)
project_ids += projects.pluck(:id).uniq
project_ids.push(*groups_projects.pluck(:id))
project_ids.push(*projects.pluck(:id).uniq)
Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC')
end
end
......
......@@ -12,11 +12,11 @@ module Gitlab
# -- all .rb files in that directory are automatically loaded.
# 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/concerns
#{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).
# :all can be used as a placeholder for all plugins not explicitly named.
......@@ -31,7 +31,7 @@ module Gitlab
config.encoding = "utf-8"
# 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.
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