Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

[WIP] add project.resolveNonRealpath to return non-realpath compared to project.resolvePath - #10856

Closed
dirk-thomas wants to merge 2 commits into
atom:masterfrom
dirk-thomas:issue9879
Closed

dirk-thomas wants to merge 2 commits into
atom:masterfrom
dirk-thomas:issue9879

Conversation

@dirk-thomas

@dirk-thomas dirk-thomas commented Feb 17, 2016 •

Copy link
Copy Markdown
Contributor

This PR is trying to address #9879.

The first commit simply changes the semantic of project.resolvePath() to return a non-realpath. Since this might break the callers expectation I will try to keep the semantic of existing API on-top as outlined in #9879 (comment) as necessary. See newer comment for current behavior.

@dirk-thomas

dirk-thomas commented Sep 7, 2016 •

Copy link
Copy Markdown
Contributor Author

The current patch changes each TextBuffer to store the non-realpath (instead of the normalized realpath). This allows providing new methods to access the non-realpath:

  • Project.resolveNonRealpath
  • Text.getNonRealpath

The existing methods of Project and TextBuffer have been updated to continue having the same semantic as before. They use the helper function Project.normalizeRealpath.

Currently this PR monkey patches the TextBuffer in the project.coffee. Once the path forward is becoming clearer this should be moved to the corresponding package.

I am not yet sure why the one test needed to be updated in the second commit (in order to pass).

But I would like to get feedback on the general approach. Any comments are welcome.

@dirk-thomas dirk-thomas changed the title [WIP] change semantic of project.resolvePath to return non-realpath [WIP] add project.resolveNonRealpath to return non-realpath compared to project.resolvePath Sep 29, 2016
@maxbrunsfeld

Copy link
Copy Markdown
Contributor

@dirk-thomas Could you explain what you'd like to do with this API when and if we add it? Are you planning on using it in packages of your own, or submitting later PRs to make existing packages use this API?

@dirk-thomas

Copy link
Copy Markdown
Contributor Author

Please see the referenced issue #9879 for some more information. The immediate use case would be the Atom build package. Currently it has no way to work with projects which contain symlinked paths. The problem is described in a ticket referenced from the issue: noseglid/atom-build#245

I plan to provide patches to the build package (and their providers) so that it supports symlinked files within projects correctly. Without support for this in the Atom core API I don't think this is possible.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

Ah ok, thanks for the explanation. I would definitely be ok with adding an API for this to TextBuffer. I think I might prefer the name getOriginalPath, rather than getNonRealPath. The idea of a non-real path sounds kind of confusing.

@dirk-thomas

Copy link
Copy Markdown
Contributor Author

For the naming imo the best would be to have getPath and getRealPath ("realpath" because that is what the two methods differentiates http://man7.org/linux/man-pages/man3/realpath.3.html). But obviously we don't want to change the semantic of the existing method. Therefore I called the new one getNonRealpath.

If you prefer getOriginalPath I can for sure update the PR. I just think that "realpath" is the right term here since its meaning is clearly defined by the same named low level API.

Once we agree on the current state of the patch (only changing Project) the next step is for me to also add the new API to TextBuffer.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

I just think that "realpath" is the right term here since its meaning is clearly defined by the same named low level API.

Good point. What about getUnresolvedPath()? The linux man page for realpath(1) refers to the output of realpath() as the "the resolved absolute file name".

…override TextBuffer.getPath to continue returning a normalized realpath, add TextBuffer.getUnresolvedPath
@dirk-thomas

Copy link
Copy Markdown
Contributor Author

I was able to rebase to master and remove some code from the patch since now fs-plus 2.9.2 is being used. I also changed TextBuffer.getNonRealpath to TextBuffer.getUnresolvedPath following your naming recommendation.

I am just not sure what a good name for the new method on Project is. Before I named it resolveNonRealpath. Based on your comments I think avoiding "resolve" is better. Therefore I updated the PR to call it Project.absolutePath but any feedback on this is welcome.

@dirk-thomas

Copy link
Copy Markdown
Contributor Author

@maxbrunsfeld Can you please take another look at the updated PR when you have some time. Thank you.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

I think absolutePath is a good name for the new method. So I think the next steps for this PR are:

  1. Submit a text-buffer PR adding getUnresolvedPath
  2. Add specs for the new Project.absolutePath method.

@dirk-thomas

Copy link
Copy Markdown
Contributor Author

Ok, thank you for the feedback. I will get on those items as soon as I find a spare minute.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

This problem was addressed in #13545.

@dirk-thomas
dirk-thomas deleted the issue9879 branch January 5, 2017 00:56
@dirk-thomas

Copy link
Copy Markdown
Contributor Author

Great. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants