Skip to content

Commit

Permalink
Fixed a bug where turning on and off the rendering of markdown files …
Browse files Browse the repository at this point in the history
…in Workspace config wouldn't turn off rendering properly and would stay in read-only mode (fixes tuist#5196) (tuist#5261)

* Fixed a bug where turning on and off the rendering of markdown files in Workspace config wouldn't turn off rendering properly and would stay in read-only mode (fixes tuist#5196)

* chore: remove bugfix comment

* remove trailing whitespace

---------

Co-authored-by: Daniele Formichelli <[email protected]>
  • Loading branch information
Buju77 and danieleformichelli committed Jul 4, 2023
1 parent 461eecd commit a9cc880
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ import TuistSupport
/// Tuist Workspace Markdown render Mapper.
///
/// A mapper that includes a .xcodesample.plist file within the generated xcworkspace directory.
/// This is used to render markdown inside the de workspace.
/// This is used to render markdown inside the workspace.
final class TuistWorkspaceRenderMarkdownReadmeMapper: WorkspaceMapping {
func map(workspace: WorkspaceWithProjects) throws -> (WorkspaceWithProjects, [SideEffectDescriptor]) {
guard workspace.workspace.generationOptions.renderMarkdownReadme else {
return (workspace, [])
}

let tuistGeneratedFileDescriptor = FileDescriptor(
path: workspace
.workspace
.xcWorkspacePath
.appending(
component: ".xcodesamplecode.plist"
),
contents: try PropertyListEncoder().encode([String]())
contents: try PropertyListEncoder().encode([String]()),
state: workspace.workspace.generationOptions.renderMarkdownReadme ? .present : .absent
)

return (workspace, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ final class TuistWorkspaceRenderMarkdownReadmeMapperTests: TuistUnitTestCase {
renderMarkdownReadme: false
))

let tuistGeneratedFileDescriptor = FileDescriptor(
path: workspace
.xcWorkspacePath
.appending(
component: ".xcodesamplecode.plist"
),
contents: try PropertyListEncoder().encode([String]()),
state: .absent // file should be deleted
)
let workspaceWithProjects = WorkspaceWithProjects(workspace: workspace, projects: [])
// When
let (gotWorkspaceWithProjects, sideEffects) = try TuistWorkspaceRenderMarkdownReadmeMapper()
Expand All @@ -78,6 +87,11 @@ final class TuistWorkspaceRenderMarkdownReadmeMapperTests: TuistUnitTestCase {
gotWorkspaceWithProjects.workspace.generationOptions.renderMarkdownReadme
)
XCTAssertTrue(gotWorkspaceWithProjects.workspace.projects.isEmpty)
XCTAssertEqual(sideEffects, [])
XCTAssertEqual(
sideEffects,
[
.file(tuistGeneratedFileDescriptor),
]
)
}
}

0 comments on commit a9cc880

Please sign in to comment.