diff --git a/bin/gitlab-backup-cli b/bin/gitlab-backup-cli index 4037684be07d6561b63c433d1e41885f91b88c99..6ddfd5d49d02514223cfd491336ba7a4c06fc7ac 100755 --- a/bin/gitlab-backup-cli +++ b/bin/gitlab-backup-cli @@ -5,7 +5,7 @@ $:.unshift File.expand_path("../../lib", __FILE__) # We require APP_PATH when the rails environment is required only, # this allows for faster CLI execution when rails is not needed -APP_PATH = File.expand_path('../config/application', __dir__) +GITLAB_PATH = File.expand_path('../', __dir__) require_relative '../config/boot' diff --git a/gems/gitlab-backup-cli/bin/console b/gems/gitlab-backup-cli/bin/console index 3aa2eb40f2184863d7ddab524512f4c30e7ed80c..0cd1d6c57f511bdc5ac22fa8b0371054b9fcdb76 100755 --- a/gems/gitlab-backup-cli/bin/console +++ b/gems/gitlab-backup-cli/bin/console @@ -7,5 +7,7 @@ require "gitlab/backup/cli" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. +GITLAB_PATH = File.expand_path(File.join(__dir__, '../../../')) + require "irb" IRB.start(__FILE__) diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli.rb index 4679c5da7aae9f4cc8edf614692813b4ffb8f61b..de526fd33af08c05004a4cf3a49f8308a038d1d1 100644 --- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli.rb +++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli.rb @@ -27,7 +27,7 @@ module Cli Error = Class.new(StandardError) def self.rails_environment! - require APP_PATH + require File.join(GITLAB_PATH, 'config/application') Rails.application.require_environment! Rails.application.autoloaders diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb index 4299f2eb2dd3cc3dcd6b078b5638fd8587b784d1..67ad70818999207861abb11baecf3a077be41674 100644 --- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb +++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/source_context.rb @@ -76,6 +76,14 @@ def env @env ||= ActiveSupport::EnvironmentInquirer.new( ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development") end + + private + + def gitlab_basedir + return GITLAB_PATH if GITLAB_PATH + + raise ::Gitlab::Backup::Cli::Error, 'GITLAB_PATH is missing' + end end end end