From 7b4576a2009b8648bb4c3f9bfee1179c048397f4 Mon Sep 17 00:00:00 2001 From: Luke Massa Date: Sun, 19 Jan 2025 23:23:28 -0500 Subject: [PATCH] chore: Clarify logs in determining merged project configs (#5255) Signed-off-by: Luke Massa --- server/events/project_command_builder.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 84a6fc860f..c06059dd33 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -379,7 +379,7 @@ func (p *DefaultProjectCommandBuilder) autoDiscoverModeEnabled(ctx *command.Cont } // getMergedProjectCfgs gets all merged project configs for building commands given a context and a clone repo -func (p *DefaultProjectCommandBuilder) getMergedProjectCfgs(ctx *command.Context, repoDir string, modifiedFiles []string, repoCfg valid.RepoCfg, hasRepoCfg bool, repoCfgFile string) ([]valid.MergedProjectCfg, error) { +func (p *DefaultProjectCommandBuilder) getMergedProjectCfgs(ctx *command.Context, repoDir string, modifiedFiles []string, repoCfg valid.RepoCfg) ([]valid.MergedProjectCfg, error) { mergedCfgs := make([]valid.MergedProjectCfg, 0) moduleInfo, err := FindModuleProjects(repoDir, p.AutoDetectModuleFiles) @@ -403,17 +403,8 @@ func (p *DefaultProjectCommandBuilder) getMergedProjectCfgs(ctx *command.Context } if p.autoDiscoverModeEnabled(ctx, repoCfg) { - // If there is no config file or it specified no projects, then we'll plan each project that - // our algorithm determines was modified. - if hasRepoCfg { - if len(repoCfg.Projects) == 0 { - ctx.Log.Info("no projects are defined in %s. Will resume automatic detection", repoCfgFile) - } else { - ctx.Log.Info("automatic project discovery enabled. Will resume automatic detection") - } - } else { - ctx.Log.Info("found no %s file", repoCfgFile) - } + ctx.Log.Info("automatic project discovery enabled. Will run automatic detection") + // build a module index for projects that are explicitly included allModifiedProjects := p.ProjectFinder.DetermineProjects( ctx.Log, modifiedFiles, ctx.Pull.BaseRepo.FullName, repoDir, p.AutoplanFileList, moduleInfo) @@ -513,9 +504,11 @@ func (p *DefaultProjectCommandBuilder) buildAllCommandsByCfg(ctx *command.Contex return nil, errors.Wrapf(err, "parsing %s", repoCfgFile) } ctx.Log.Info("successfully parsed %s file", repoCfgFile) + } else { + ctx.Log.Info("repo config file %s is absent, using global defaults", repoCfg) } - mergedProjectCfgs, err := p.getMergedProjectCfgs(ctx, repoDir, modifiedFiles, repoCfg, hasRepoCfg, repoCfgFile) + mergedProjectCfgs, err := p.getMergedProjectCfgs(ctx, repoDir, modifiedFiles, repoCfg) if err != nil { return nil, err }