Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where .manifest files didn't register as roots #1081

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/io/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func WalkFiles(root string, f func(path string) error) error {
})
}

// FindManifestLocations walks the file system rooted at root, and returns the
// *relative* paths of directories containing a .manifest file.
func FindManifestLocations(root string) ([]string, error) {
var foundBundleRoots []string

Expand Down
10 changes: 8 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func FindRegalDirectory(path string) (*os.File, error) {
//
// - Configuration (`project.roots`)
// - By the presence of a .manifest file anywhere under the path
// - By the presence of a .regal directory anywhere under or above the path ... TODO (anders): might reconsider "above"?
// - By the presence of a .regal directory anywhere under or above the path ...
//
// All returned paths are absolute paths. If the provided path itself
// is determined to be a bundle root directory it will be included in the result.
Expand Down Expand Up @@ -219,7 +219,6 @@ func FindBundleRootDirectories(path string) ([]string, error) {
foundBundleRoots = append(foundBundleRoots, roots...)
}

// rather than calling rio.FindManifestLocations later, let's
// check for .manifest directories as part of the same walk
if !info.IsDir() && info.Name() == ".manifest" {
foundBundleRoots = append(foundBundleRoots, filepath.Dir(path))
Expand Down Expand Up @@ -268,6 +267,13 @@ func rootsFromRegalDirectory(regalDir *os.File) ([]string, error) {
foundBundleRoots = append(foundBundleRoots, customRulesDir)
}

manifestRoots, err := rio.FindManifestLocations(filepath.Dir(regalDir.Name()))
if err != nil {
return nil, fmt.Errorf("failed while looking for manifest locations: %w", err)
}

foundBundleRoots = append(foundBundleRoots, util.Map(util.FilepathJoiner(parent), manifestRoots)...)

return foundBundleRoots, nil
}

Expand Down