Skip to content

Commit

Permalink
chore: Clarify logs in determining merged project configs (#5255)
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Massa <[email protected]>
  • Loading branch information
lukemassa authored Jan 20, 2025
1 parent 713bc7d commit 7b4576a
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions server/events/project_command_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 7b4576a

Please sign in to comment.