From e5acbed8488f7e633b2fe1b95f44b9edbd4e94fc Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 8 Aug 2025 20:12:05 +0200 Subject: [PATCH] Cleanup: move UpdateWindowTitle to platform-specific source files No need to do a runtime check if we already have the platform-specific files. --- pkg/commands/oscommands/os.go | 13 ------------- pkg/commands/oscommands/os_default_platform.go | 4 ++++ pkg/commands/oscommands/os_windows.go | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index b14738e38..f070e4856 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -1,7 +1,6 @@ package oscommands import ( - "fmt" "io" "os" "os/exec" @@ -329,15 +328,3 @@ func GetLazygitPath() string { } return `"` + filepath.ToSlash(ex) + `"` } - -func (c *OSCommand) UpdateWindowTitle() error { - if c.Platform.OS != "windows" { - return nil - } - path, getWdErr := os.Getwd() - if getWdErr != nil { - return getWdErr - } - argString := fmt.Sprint("title ", filepath.Base(path), " - Lazygit") - return c.Cmd.NewShell(argString, c.UserConfig().OS.ShellFunctionsFile).Run() -} diff --git a/pkg/commands/oscommands/os_default_platform.go b/pkg/commands/oscommands/os_default_platform.go index 11e1dc9aa..5ea872c8c 100644 --- a/pkg/commands/oscommands/os_default_platform.go +++ b/pkg/commands/oscommands/os_default_platform.go @@ -34,3 +34,7 @@ func getUserShell() string { return "bash" } + +func (c *OSCommand) UpdateWindowTitle() error { + return nil +} diff --git a/pkg/commands/oscommands/os_windows.go b/pkg/commands/oscommands/os_windows.go index 783f50518..0c69ca685 100644 --- a/pkg/commands/oscommands/os_windows.go +++ b/pkg/commands/oscommands/os_windows.go @@ -1,5 +1,11 @@ package oscommands +import ( + "fmt" + "os" + "path/filepath" +) + func GetPlatform() *Platform { return &Platform{ OS: "windows", @@ -7,3 +13,12 @@ func GetPlatform() *Platform { ShellArg: "/c", } } + +func (c *OSCommand) UpdateWindowTitle() error { + path, getWdErr := os.Getwd() + if getWdErr != nil { + return getWdErr + } + argString := fmt.Sprint("title ", filepath.Base(path), " - Lazygit") + return c.Cmd.NewShell(argString, c.UserConfig().OS.ShellFunctionsFile).Run() +}