Skip to content

Deprecate stand-alone currentWorkingDirectory #1588

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

Merged

Conversation

vlm
Copy link
Contributor

@vlm vlm commented Jun 1, 2018

Rationale

When a directory gets removed from under the running SwiftPM-based application, an irrecoverable error is generated. We'd like to be able to catch the error earlier.

Changes

  • deprecated stand-alone currentWorkingDirectory
  • introduced per-FileSystem currentWorkingDirectory which returns an optional AbsolutePath result.
  • made a bunch of changes throughout the code which made sense. In some cases an explicit unwrapping is added, in some other a semantically reasonable behavior is codified.

@vlm vlm added the WIP Work in progress label Jun 1, 2018
@vlm vlm requested a review from aciidgh June 1, 2018 18:15
Copy link
Contributor

@aciidgh aciidgh left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

I added two minor nits.

@@ -735,9 +735,12 @@ extension BuildSubset {
/// Returns path of the nearest directory containing the manifest file w.r.t
/// current working directory.
private func findPackageRoot() -> AbsolutePath? {
guard let cwd = localFileSystem.currentWorkingDirectory else {
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just be guard var root = ...

guard value.hasPrefix("/") else {
return nil
}
path = AbsolutePath(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be more clear:

if let cwd = currentWorkingDirectory {
    path = AbsolutePath(value, relativeTo: cwd)
} else if let absPath = try? AbsolutePath(validating: value) {
    path = absPath
} else {
    return nil
}

@vlm vlm force-pushed the deprecate-standalone-currentWorkingDirectory branch from 2d7692d to 241d43d Compare June 1, 2018 23:50
@vlm
Copy link
Contributor Author

vlm commented Jun 1, 2018

@swift-ci please smoke test

@vlm vlm removed the WIP Work in progress label Jun 1, 2018
@vlm vlm merged commit 5fd01de into swiftlang:master Jun 2, 2018
@vlm vlm deleted the deprecate-standalone-currentWorkingDirectory branch June 2, 2018 00:50
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.

2 participants