From e389ffa137a1c4a959985a898aa882e757a38a22 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 14 Nov 2023 13:22:46 +0000 Subject: [PATCH] Chore: only show short commit hash in the help menu (#78038) only show short commit hash in the help menu --- pkg/services/navtree/navtreeimpl/navtree.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/services/navtree/navtreeimpl/navtree.go b/pkg/services/navtree/navtreeimpl/navtree.go index 366de94a796..3da2b05213b 100644 --- a/pkg/services/navtree/navtreeimpl/navtree.go +++ b/pkg/services/navtree/navtreeimpl/navtree.go @@ -189,9 +189,18 @@ func isSupportBundlesEnabled(s *ServiceImpl) bool { return s.cfg.SectionWithEnvOverrides("support_bundles").Key("enabled").MustBool(true) } +// don't need to show the full commit hash in the UI +// let's substring to 10 chars like local git does automatically +func getShortCommitHash(commitHash string, maxLength int) string { + if len(commitHash) > maxLength { + return commitHash[:maxLength] + } + return commitHash +} + func (s *ServiceImpl) addHelpLinks(treeRoot *navtree.NavTreeRoot, c *contextmodel.ReqContext) { if setting.HelpEnabled { - helpVersion := fmt.Sprintf(`%s v%s (%s)`, setting.ApplicationName, setting.BuildVersion, setting.BuildCommit) + helpVersion := fmt.Sprintf(`%s v%s (%s)`, setting.ApplicationName, setting.BuildVersion, getShortCommitHash(setting.BuildCommit, 10)) if s.cfg.AnonymousHideVersion && !c.IsSignedIn { helpVersion = setting.ApplicationName }