From 4e43826c5ca726a5d87b0daffb2f28a77c5fdcc5 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Thu, 13 Aug 2020 13:31:59 +0200 Subject: [PATCH] cmd/version: skip server start to get the current mattermost version (#15234) --- cmd/mattermost/commands/version.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/mattermost/commands/version.go b/cmd/mattermost/commands/version.go index a502fc7d6c..e32ee362b7 100644 --- a/cmd/mattermost/commands/version.go +++ b/cmd/mattermost/commands/version.go @@ -16,10 +16,18 @@ var VersionCmd = &cobra.Command{ } func init() { + VersionCmd.Flags().Bool("skip-server-start", false, "Skip the server initialization and return the Mattermost version without the DB version.") + RootCmd.AddCommand(VersionCmd) } func versionCmdF(command *cobra.Command, args []string) error { + skipStart, _ := command.Flags().GetBool("skip-server-start") + if skipStart { + printVersionNoDB() + return nil + } + a, err := InitDBCommandContextCobra(command) if err != nil { return err @@ -31,10 +39,14 @@ func versionCmdF(command *cobra.Command, args []string) error { } func printVersion(a *app.App) { + printVersionNoDB() + CommandPrintln("DB Version: " + a.Srv().Store.GetCurrentSchemaVersion()) +} + +func printVersionNoDB() { CommandPrintln("Version: " + model.CurrentVersion) CommandPrintln("Build Number: " + model.BuildNumber) CommandPrintln("Build Date: " + model.BuildDate) CommandPrintln("Build Hash: " + model.BuildHash) CommandPrintln("Build Enterprise Ready: " + model.BuildEnterpriseReady) - CommandPrintln("DB Version: " + a.Srv().Store.GetCurrentSchemaVersion()) }