From 4a8ad0cc09478d01a3eb496e899f7b3318f84939 Mon Sep 17 00:00:00 2001 From: Beau Date: Fri, 22 Mar 2024 20:01:39 +0000 Subject: [PATCH] fix: remove directory from project name when context is self --- repocfg/util.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/repocfg/util.go b/repocfg/util.go index 3b32102..fdfe71a 100644 --- a/repocfg/util.go +++ b/repocfg/util.go @@ -9,8 +9,15 @@ import ( func ptr[T any](v T) *T { return &v } // friendlyName creates a contextual name used for Atlantis projects -func friendlyName(path, environment string) string { - name := []string{strings.ReplaceAll(path, "/", "-"), pathWithoutExtension(filepath.Base(environment))} +func friendlyName(path, varFile string) string { + environment := pathWithoutExtension(filepath.Base(varFile)) + + // avoid constructing a joined path if the context is the current directory + if filepath.Base(path) == "." { + return environment + } + + name := []string{strings.ReplaceAll(path, "/", "-"), environment} return strings.TrimSuffix(strings.Join(name, "-"), "-") }