Limit readiness scans to selected package inputs
This commit is contained in:
@@ -386,6 +386,30 @@ func ReadTree(ctx context.Context, repositoryDir, commit string) ([]TreeEntry, e
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
// ReadTreeDirectory lists immediate entries of a resolved repository-relative
|
||||
// directory in a captured commit. Entry paths remain repository-relative.
|
||||
func ReadTreeDirectory(ctx context.Context, repositoryDir, commit, directory string) ([]TreeEntry, error) {
|
||||
if !validObjectID(commit) {
|
||||
return nil, fmt.Errorf("invalid commit object ID %q", commit)
|
||||
}
|
||||
if directory == "" || path.IsAbs(directory) || path.Clean(directory) != directory || directory == ".." || strings.HasPrefix(directory, "../") {
|
||||
return nil, fmt.Errorf("invalid committed directory %q", directory)
|
||||
}
|
||||
args := []string{"--literal-pathspecs", "ls-tree", "-z", "--full-tree", commit}
|
||||
if directory != "." {
|
||||
args = append(args, "--", directory+"/")
|
||||
}
|
||||
output, err := readLocalObjects(ctx, repositoryDir, nil, args...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("enumerate committed directory %q: %w", directory, err)
|
||||
}
|
||||
entries, err := parseTreeEntries(output)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse committed directory %q: %w", directory, err)
|
||||
}
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
// ReadBlob reads the bytes for a Git blob object ID without consulting the
|
||||
// worktree.
|
||||
func ReadBlob(ctx context.Context, repositoryDir, objectID string) ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user