Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating intermediary groups outside of the project directory #892

Conversation

segiddins
Copy link
Contributor

Resolves #889

Putting this out as a potential solution -- I'm new to the codebase, so I'm not sure if there's maybe a better way of doing this, or if there's a reason this is unacceptable. Just wanted to try it out, since it makes the projects we're generating via bazel in a scratch directory nicer to edit

@segiddins segiddins force-pushed the segiddins/889-create-intermediadary-groups-outside-of-project-dir branch from a0aad0e to c5013d5 Compare June 16, 2020 23:00
@@ -492,7 +492,7 @@ class SourceGeneratorTests: XCTestCase {
let pbxProj = try project.generatePbxProj()
try pbxProj.expectFile(paths: ["Sources", "A", "b.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["Sources", "F", "G", "h.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["../OtherDirectory/C/D", "e.swift"], names: ["D", "e.swift"], buildPhase: .sources)
try pbxProj.expectFile(paths: ["..", "OtherDirectory", "C", "D", "e.swift"], names: [".", "OtherDirectory", "C", "D", "e.swift"], buildPhase: .sources)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there other test cases you can think of for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really

Copy link
Owner

@yonaskolb yonaskolb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @segiddins. I'm trying to think of why this wasn't done before. Can you envisage any issues when running this with a different --spec or --project path? There aren't enough tests around those use cases.

Could you also add a changelog entry

@segiddins
Copy link
Contributor Author

I'll try to pick this back up next week, thanks for the review!

@segiddins segiddins force-pushed the segiddins/889-create-intermediadary-groups-outside-of-project-dir branch from c5013d5 to 84f1daf Compare August 6, 2020 00:29
@segiddins
Copy link
Contributor Author

@yonaskolb this should be ready now, sorry for the delay!

@segiddins
Copy link
Contributor Author

@yonaskolb any other changes you'd like me to make?

// has no valid parent paths
let isRootPath = (isBaseGroup && isOutOfBasePath) || path.parent() == project.basePath
let isRootPath = (isBaseGroup && isOutOfBasePath && isParentOfBasePath) || path.parent() == project.basePath
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line can lose the && isParentOfBasePath.
isOutOfBasePath captures the intent and isRootPath is used in the line below. Or am I reading it wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it can. For example, for a project in ., ../foo/bar.txt shouldn't be considered the root path -- the root path should be a strict parent of the current directory

@segiddins
Copy link
Contributor Author

Ping on merging this before the next release?

@keith keith merged commit c8b24ac into yonaskolb:master Sep 2, 2020
@segiddins segiddins deleted the segiddins/889-create-intermediadary-groups-outside-of-project-dir branch September 2, 2020 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

createIntermediateGroups doesn't work for files outside of the project directory
3 participants