@@ -33,9 +33,10 @@ struct DownstreamArgument: ParsableCommand {
33
33
}
34
34
35
35
// Associations file is used in place of an actual file during tests
36
- func todos( fileList: [ String ] ) throws -> TodoList {
36
+ func todos( fileList: [ String ] , associationsFiles : [ String : AssociationsFile ] ? = nil ) throws -> TodoList {
37
37
return try fileList. reduce ( into: TodoList ( ) ) { ( result, filePath) in
38
- let matches = try matches ( forFile: filePath)
38
+ let parent = URL ( fileURLWithPath: filePath) . deletingLastPathComponent ( ) . path
39
+ let matches = try matches ( forFile: filePath, associationsFile: associationsFiles ? [ parent] )
39
40
if !matches. isEmpty {
40
41
result [ filePath] = matches
41
42
}
@@ -46,12 +47,13 @@ struct DownstreamArgument: ParsableCommand {
46
47
let decoder = YAMLDecoder ( )
47
48
48
49
if let associationsFile = associationsFile {
49
- return associationsFile. associations. matches ( path)
50
+ let changedFile = URL ( fileURLWithPath: path)
51
+ return associationsFile. associations. matches ( changedFile. lastPathComponent)
50
52
} else {
51
53
// This path should be coming from git diff, so we expect it to be valid
52
54
let changedFile = URL ( fileURLWithPath: path)
53
55
let parent = changedFile. deletingLastPathComponent ( )
54
- let downstreamYML = changedFile . appendingPathComponent ( " downstream.yml " )
56
+ let downstreamYML = parent . appendingPathComponent ( " downstream.yml " )
55
57
56
58
if
57
59
let contentData = FileManager . default. contents ( atPath: downstreamYML. path) ,
0 commit comments