mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 19:11:14 +08:00
DEV: Redo DiscourseLogstashLogger
to not rely on logstash-logger
(#27759)
This reverts commit 92d7d24d0ffbf3e224af19eda2b24df740df056b.
This commit is contained in:

committed by
GitHub

parent
b46e1fe2aa
commit
28f5550886
@ -4,6 +4,7 @@ require "cache"
|
||||
require "open3"
|
||||
require "plugin/instance"
|
||||
require "version"
|
||||
require "git_utils"
|
||||
|
||||
module Discourse
|
||||
DB_POST_MIGRATE_PATH ||= "db/post_migrate"
|
||||
@ -829,42 +830,23 @@ 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
|
||||
@git_version ||= GitUtils.git_version
|
||||
end
|
||||
|
||||
def self.git_branch
|
||||
@git_branch ||=
|
||||
self.try_git("git branch --show-current", nil) ||
|
||||
self.try_git("git config user.discourse-version", "unknown")
|
||||
@git_branch ||= GitUtils.git_branch
|
||||
end
|
||||
|
||||
def self.full_version
|
||||
@full_version ||=
|
||||
begin
|
||||
git_cmd = 'git describe --dirty --match "v[0-9]*" 2> /dev/null'
|
||||
self.try_git(git_cmd, "unknown")
|
||||
end
|
||||
@full_version ||= GitUtils.full_version
|
||||
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 ||= GitUtils.last_commit_date
|
||||
end
|
||||
|
||||
def self.try_git(git_cmd, default_value)
|
||||
begin
|
||||
`#{git_cmd}`.strip
|
||||
rescue StandardError
|
||||
default_value
|
||||
end.presence || default_value
|
||||
GitUtils.try_git(git_cmd, default_value)
|
||||
end
|
||||
|
||||
# Either returns the site_contact_username user or the first admin.
|
||||
|
Reference in New Issue
Block a user