Skip to content

Commit

Permalink
fix: resolve symlinks for startup and git
Browse files Browse the repository at this point in the history
  • Loading branch information
smitropoulos committed Dec 2, 2023
1 parent 1555503 commit e5c0c19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/app/entry_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/commands/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e5c0c19

Please sign in to comment.