change dir resolver to include virtual path (#2259)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2023-11-02 08:20:00 -04:00
committed by GitHub
parent 26cdbfc299
commit 6c41f15975
8 changed files with 27 additions and 35 deletions
@@ -48,7 +48,7 @@ func Test_allRegularFiles(t *testing.T) {
return r
},
wantRealPaths: strset.New("file1.txt", "nested/file2.txt"),
wantVirtualPaths: strset.New("nested/linked-file1.txt"),
wantVirtualPaths: strset.New("file1.txt", "nested/file2.txt", "nested/linked-file1.txt"),
},
}
for _, tt := range tests {
+4 -4
View File
@@ -68,6 +68,7 @@ func NewLocation(realPath string) Location {
Coordinates: Coordinates{
RealPath: realPath,
},
VirtualPath: realPath,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -94,6 +95,7 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location {
return Location{
LocationData: LocationData{
Coordinates: coordinates,
VirtualPath: coordinates.RealPath,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -137,7 +139,8 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location
Coordinates: Coordinates{
RealPath: responsePath,
},
ref: ref,
VirtualPath: responsePath,
ref: ref,
},
LocationMetadata: LocationMetadata{
Annotations: map[string]string{},
@@ -147,9 +150,6 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location
// NewVirtualLocationFromDirectory creates a new Location representing the given path (extracted from the Reference) relative to the given directory with a separate virtual access path.
func NewVirtualLocationFromDirectory(responsePath, virtualResponsePath string, ref file.Reference) Location {
if responsePath == virtualResponsePath {
return NewLocationFromDirectory(responsePath, ref)
}
return Location{
LocationData: LocationData{
Coordinates: Coordinates{