Skip to content

Commit bff5006

Browse files
ndeloofglours
authored andcommitted
detect project dir is a symlink and warn user
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 35c9659 commit bff5006

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cli/options.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,13 @@ func withNamePrecedenceLoad(absWorkingDir string, options *ProjectOptions) func(
502502
} else if nameFromEnv, ok := options.Environment[consts.ComposeProjectName]; ok && nameFromEnv != "" {
503503
opts.SetProjectName(nameFromEnv, true)
504504
} else {
505+
dirname := filepath.Base(absWorkingDir)
506+
symlink, err := filepath.EvalSymlinks(absWorkingDir)
507+
if err == nil && filepath.Base(symlink) != dirname {
508+
logrus.Warnf("project has been loaded without an explicit name from a symlink. Using name %q", dirname)
509+
}
505510
opts.SetProjectName(
506-
loader.NormalizeProjectName(filepath.Base(absWorkingDir)),
511+
loader.NormalizeProjectName(dirname),
507512
false,
508513
)
509514
}

0 commit comments

Comments
 (0)