mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Avoid $
globals (#15453)
Also: * Remove an unused method (#fill_email) * Replace a method that was used just once (#generate_username) with `SecureRandom.alphanumeric` * Remove an obsolete dev puma `tmp/restart` file logic
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
# rubocop:disable Style/GlobalVars
|
||||
|
||||
require 'cache'
|
||||
require 'open3'
|
||||
@ -653,36 +652,32 @@ module Discourse
|
||||
end
|
||||
|
||||
def self.git_version
|
||||
$git_version ||=
|
||||
begin
|
||||
git_cmd = 'git rev-parse HEAD'
|
||||
self.try_git(git_cmd, Discourse::VERSION::STRING)
|
||||
end # rubocop:disable Style/GlobalVars
|
||||
@git_version ||= begin
|
||||
git_cmd = 'git rev-parse HEAD'
|
||||
self.try_git(git_cmd, Discourse::VERSION::STRING)
|
||||
end
|
||||
end
|
||||
|
||||
def self.git_branch
|
||||
$git_branch ||=
|
||||
begin
|
||||
git_cmd = 'git rev-parse --abbrev-ref HEAD'
|
||||
self.try_git(git_cmd, 'unknown')
|
||||
end
|
||||
@git_branch ||= begin
|
||||
git_cmd = 'git rev-parse --abbrev-ref HEAD'
|
||||
self.try_git(git_cmd, 'unknown')
|
||||
end
|
||||
end
|
||||
|
||||
def self.full_version
|
||||
$full_version ||=
|
||||
begin
|
||||
git_cmd = 'git describe --dirty --match "v[0-9]*"'
|
||||
self.try_git(git_cmd, 'unknown')
|
||||
end
|
||||
@full_version ||= begin
|
||||
git_cmd = 'git describe --dirty --match "v[0-9]*"'
|
||||
self.try_git(git_cmd, 'unknown')
|
||||
end
|
||||
end
|
||||
|
||||
def self.last_commit_date
|
||||
$last_commit_date ||=
|
||||
begin
|
||||
git_cmd = 'git log -1 --format="%ct"'
|
||||
seconds = self.try_git(git_cmd, nil)
|
||||
seconds.nil? ? nil : DateTime.strptime(seconds, '%s')
|
||||
end
|
||||
@last_commit_date ||= begin
|
||||
git_cmd = 'git log -1 --format="%ct"'
|
||||
seconds = self.try_git(git_cmd, nil)
|
||||
seconds.nil? ? nil : DateTime.strptime(seconds, '%s')
|
||||
end
|
||||
end
|
||||
|
||||
def self.try_git(git_cmd, default_value)
|
||||
@ -1001,9 +996,7 @@ module Discourse
|
||||
@preloaded_rails = true
|
||||
end
|
||||
|
||||
def self.redis
|
||||
$redis
|
||||
end
|
||||
mattr_accessor :redis
|
||||
|
||||
def self.is_parallel_test?
|
||||
ENV['RAILS_ENV'] == "test" && ENV['TEST_ENV_NUMBER']
|
||||
@ -1031,5 +1024,3 @@ module Discourse
|
||||
Rails.env.development? || ENV["ALLOW_DEV_POPULATE"] == "1"
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:enable Style/GlobalVars
|
||||
|
Reference in New Issue
Block a user