From e5c0c1997cdfb51cb2341495ddb89797a6838e94 Mon Sep 17 00:00:00 2001 From: Stefanos Mitropoulos Date: Sat, 2 Dec 2023 21:44:36 +0200 Subject: [PATCH 1/2] fix: resolve symlinks for startup and git --- pkg/app/entry_point.go | 5 +++++ pkg/commands/git.go | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/app/entry_point.go b/pkg/app/entry_point.go index fb19f06f6c6..df40854d890 100644 --- a/pkg/app/entry_point.go +++ b/pkg/app/entry_point.go @@ -59,6 +59,11 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes log.Fatal(err) } + absRepoPath, err = filepath.EvalSymlinks(cliArgs.RepoPath) + if err != nil { + log.Fatal(err) + } + if isRepo, err := isDirectoryAGitRepository(absRepoPath); err != nil || !isRepo { log.Fatal(absRepoPath + " is not a valid git repository.") } diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 51066103416..f5496854a13 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -64,10 +64,21 @@ func NewGitCommand( gitConfig git_config.IGitConfig, ) (*GitCommand, error) { currentPath, err := os.Getwd() + if err != nil { return nil, utils.WrapError(err) } + // Check if the current path is a symlink and walk it + absRepoPath, err := filepath.EvalSymlinks(currentPath) + if err != nil { + return nil, utils.WrapError(err) + } + + if absRepoPath != currentPath { + currentPath = absRepoPath + } + // converting to forward slashes for the sake of windows (which uses backwards slashes). We want everything // to have forward slashes internally currentPath = filepath.ToSlash(currentPath) From 46c9f2812bc3a2d93a19fc456d49f9897ec18663 Mon Sep 17 00:00:00 2001 From: Stefanos Mitropoulos Date: Sat, 2 Dec 2023 23:12:26 +0200 Subject: [PATCH 2/2] fix: fmt --- pkg/commands/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index f5496854a13..c9249a0dadf 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -69,7 +69,7 @@ func NewGitCommand( return nil, utils.WrapError(err) } - // Check if the current path is a symlink and walk it + // Check if the current path is a symlink and walk it absRepoPath, err := filepath.EvalSymlinks(currentPath) if err != nil { return nil, utils.WrapError(err)