File tree Expand file tree Collapse file tree 4 files changed +37
-6
lines changed
Expand file tree Collapse file tree 4 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,20 @@ struct InputPathTests {
3333 #expect( path. lastComponent == " file.swift " )
3434 }
3535
36+ @Test
37+ func inputPath_lastComponent_shouldReturnSameValue_whenContainsOnlyFileName( ) {
38+ let path = InputPath ( " file.swift " , projectRoot: projectRoot)
39+
40+ #expect( path. lastComponent == " file.swift " )
41+ }
42+
43+ @Test
44+ func inputPath_lastComponent_shouldReturnSameValue_whenContainsOnlyGroupName( ) {
45+ let path = InputPath ( " GroupXYZ " , projectRoot: projectRoot)
46+
47+ #expect( path. lastComponent == " GroupXYZ " )
48+ }
49+
3650 @Test
3751 func inputPath_firstRelativeComponent_shouldReturnCorrectValue( ) {
3852 let path = InputPath ( filePath, projectRoot: projectRoot)
Original file line number Diff line number Diff line change @@ -109,9 +109,9 @@ final class ProjectFiles {
109109
110110 // Rename if needed
111111 if filePath. lastComponent != newPath. lastComponent {
112- fileRef. sourceTree = . group
113- fileRef. name = newPath. lastComponent
112+ fileRef. name = nil
114113 fileRef. path = newPath. lastComponent
114+ fileRef. setGroupSourceTree ( )
115115 }
116116
117117 return targets. map ( \. name)
@@ -122,8 +122,8 @@ final class ProjectFiles {
122122 throw CLIError . fileNotFoundInProject ( filePath)
123123 }
124124
125- file. sourceTree = . group
126- file. name = newName
125+ file. name = nil
127126 file. path = newName
127+ file. setGroupSourceTree ( )
128128 }
129129}
Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ final class ProjectGroups {
4848 throw CLIError . groupNotFoundInProject ( groupPath)
4949 }
5050
51- group. sourceTree = . group
52- group. name = newName
51+ group. name = nil
5352 group. path = newName
53+ group. setGroupSourceTree ( )
5454 }
5555
5656 func deleteGroup( _ groupPath: InputPath ) throws {
@@ -80,6 +80,7 @@ final class ProjectGroups {
8080 try mergeGroups ( from: group, into: existingGroup)
8181 project. pbxproj. delete ( object: group)
8282 } else {
83+ group. setGroupSourceTree ( )
8384 destinationGroup. children. append ( group)
8485 }
8586 }
@@ -95,6 +96,7 @@ final class ProjectGroups {
9596 project. pbxproj. delete ( object: sourceChildGroup)
9697 } else {
9798 sourceChildGroup. parent = target
99+ sourceChildGroup. setGroupSourceTree ( )
98100 target. children. append ( sourceChildGroup)
99101 }
100102
@@ -111,6 +113,7 @@ final class ProjectGroups {
111113 try projectFiles. removeFile ( fileRef. fullPath!)
112114 } else {
113115 fileRef. parent = target
116+ fileRef. setGroupSourceTree ( )
114117 target. children. append ( fileRef)
115118 }
116119
Original file line number Diff line number Diff line change @@ -8,4 +8,18 @@ extension PBXFileElement {
88
99 return try ? fullPath ( sourceRoot: Project . projectRoot) ? . asInputPath
1010 }
11+
12+ func setGroupSourceTree( ) {
13+ if sourceTree != . group {
14+ sourceTree = . group
15+ name = nil
16+ path = path? . asInputPath. lastComponent
17+ }
18+
19+ if let group = self as? PBXGroup {
20+ for child in group. children {
21+ child. setGroupSourceTree ( )
22+ }
23+ }
24+ }
1125}
You can’t perform that action at this time.
0 commit comments