From afc4a75499b6678a643e6b62f703f8e7e1eb0f0a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 14:52:01 -0400 Subject: [PATCH] Use Rails.root.join where appropriate --- app/controllers/application_controller.rb | 2 +- app/models/merge_request.rb | 2 +- app/roles/repository.rb | 2 +- config/initializers/1_settings.rb | 2 +- db/fixtures/test/001_repo.rb | 4 ++-- lib/gitlab/backend/gitolite_config.rb | 4 ++-- lib/gitlab/logger.rb | 2 +- lib/gitlab/merge.rb | 4 ++-- lib/gitlab/satellite.rb | 6 +++--- spec/models/project_spec.rb | 2 +- spec/support/stubbed_repository.rb | 4 ++-- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f5d978a7e..334135c89 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -105,7 +105,7 @@ class ApplicationController < ActionController::Base end def render_404 - render file: File.join(Rails.root, "public", "404"), layout: false, status: "404" + render file: Rails.root.join("public", "404"), layout: false, status: "404" end def require_non_empty_project diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index bb7b53fac..717fe2969 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1,4 +1,4 @@ -require File.join(Rails.root, "app/models/commit") +require Rails.root.join("app/models/commit") class MergeRequest < ActiveRecord::Base include IssueCommonality diff --git a/app/roles/repository.rb b/app/roles/repository.rb index 1f44481e4..35093a2fc 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -155,7 +155,7 @@ module Repository # Build file path file_name = self.code + "-" + commit.id.to_s + ".tar.gz" - storage_path = File.join(Rails.root, "tmp", "repositories", self.code) + storage_path = Rails.root.join("tmp", "repositories", self.code) file_path = File.join(storage_path, file_name) # Put files into a directory before archiving diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 7a7ca43f1..276707a73 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -112,7 +112,7 @@ class Settings < Settingslogic def backup_path t = app['backup_path'] || "backups/" - t = /^\//.match(t) ? t : File.join(Rails.root + t) + t = /^\//.match(t) ? t : Rails.root .join(t) t end diff --git a/db/fixtures/test/001_repo.rb b/db/fixtures/test/001_repo.rb index 67d4e7bfb..18fc37cde 100644 --- a/db/fixtures/test/001_repo.rb +++ b/db/fixtures/test/001_repo.rb @@ -3,13 +3,13 @@ require 'fileutils' print "Unpacking seed repository..." SEED_REPO = 'seed_project.tar.gz' -REPO_PATH = File.join(Rails.root, 'tmp', 'repositories') +REPO_PATH = Rails.root.join('tmp', 'repositories') # Make whatever directories we need to make FileUtils.mkdir_p(REPO_PATH) # Copy the archive to the repo path -FileUtils.cp(File.join(Rails.root, 'spec', SEED_REPO), REPO_PATH) +FileUtils.cp(Rails.root.join('spec', SEED_REPO), REPO_PATH) # chdir to the repo path FileUtils.cd(REPO_PATH) do diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index f51e8efc3..ffe15fb11 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -10,7 +10,7 @@ module Gitlab attr_reader :config_tmp_dir, :ga_repo, :conf def config_tmp_dir - @config_tmp_dir ||= File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}") + @config_tmp_dir ||= Rails.root.join('tmp',"gitlabhq-gitolite-#{Time.now.to_i}") end def ga_repo @@ -19,7 +19,7 @@ module Gitlab def apply Timeout::timeout(30) do - File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f| + File.open(Rails.root.join('tmp', "gitlabhq-gitolite.lock"), "w+") do |f| begin # Set exclusive lock # to prevent race condition diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 9405163dc..cf9a4c4af 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -15,7 +15,7 @@ module Gitlab end def self.build - new(File.join(Rails.root, "log", file_name)) + new(Rails.root.join("log", file_name)) end end end diff --git a/lib/gitlab/merge.rb b/lib/gitlab/merge.rb index 180135745..de8e737a8 100644 --- a/lib/gitlab/merge.rb +++ b/lib/gitlab/merge.rb @@ -28,7 +28,7 @@ module Gitlab def process Grit::Git.with_timeout(30.seconds) do - lock_file = File.join(Rails.root, "tmp", "merge_repo_#{project.path}.lock") + lock_file = Rails.root.join("tmp", "merge_repo_#{project.path}.lock") File.open(lock_file, "w+") do |f| f.flock(File::LOCK_EX) @@ -36,7 +36,7 @@ module Gitlab unless project.satellite.exists? raise "You should run: rake gitlab:app:enable_automerge" end - + project.satellite.clear Dir.chdir(project.satellite.path) do diff --git a/lib/gitlab/satellite.rb b/lib/gitlab/satellite.rb index 4bcbfe8db..9d8dfb8e0 100644 --- a/lib/gitlab/satellite.rb +++ b/lib/gitlab/satellite.rb @@ -1,6 +1,6 @@ module Gitlab class Satellite - + PARKING_BRANCH = "__parking_branch" attr_accessor :project @@ -14,7 +14,7 @@ module Gitlab end def path - File.join(Rails.root, "tmp", "repo_satellites", project.path) + Rails.root.join("tmp", "repo_satellites", project.path) end def exists? @@ -36,6 +36,6 @@ module Gitlab end end end - + end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index c313b58ec..bb975a93d 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -125,7 +125,7 @@ describe Project do it "should return path to repo" do project = Project.new(path: "somewhere") - project.path_to_repo.should == File.join(Rails.root, "tmp", "repositories", "somewhere") + project.path_to_repo.should == Rails.root.join("tmp", "repositories", "somewhere") end it "returns the full web URL for this repo" do diff --git a/spec/support/stubbed_repository.rb b/spec/support/stubbed_repository.rb index 90491e430..5bf3ea460 100644 --- a/spec/support/stubbed_repository.rb +++ b/spec/support/stubbed_repository.rb @@ -5,11 +5,11 @@ module StubbedRepository if new_record? || path == 'newproject' # There are a couple Project specs and features that expect the Project's # path to be in the returned path, so let's patronize them. - File.join(Rails.root, 'tmp', 'repositories', path) + Rails.root.join('tmp', 'repositories', path) else # For everything else, just give it the path to one of our real seeded # repos. - File.join(Rails.root, 'tmp', 'repositories', 'gitlabhq') + Rails.root.join('tmp', 'repositories', 'gitlabhq') end end -- 2.11.0