This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Add symlink resolver so we can figure out paths properly#193
Merged
Conversation
This reverts commit cac6b23.
Fixes #192 On non-windows, git and other files might be symlinks, so when we're using them as a base for determining parent directories, we may need to resolve the symlink first. The rules for automatically doing symlink resolution are tricky, so for now just do it manually.
We want the GitExecutablePath to reflect where the binary was found, and the GitInstallPath to reflect where it is installed. When the binary is a symlink (like /usr/local/bin/git -> ../Cellar/git/2.12.2/bin/git), this means GitExecutablePath will have /usr/local/bin/git and GitInstallPath will have /usr/local/Cellar/git/2.12.2/bin
|
|
||
| public bool DirectoryExists(NPath append) | ||
| { | ||
| if (append == null) |
Contributor
There was a problem hiding this comment.
If this method was sent null before, what was the result?
Member
Author
There was a problem hiding this comment.
Combine doesn't care if it's null so it wouldn't blow up, but it's a waste of resources creating new instances of the same thing over and over again, Combine always creates a new thing.
| if (path == null || DefaultEnvironment.OnWindows || path.IsRelative || !path.FileExists()) | ||
| return path; | ||
|
|
||
| return new NPath(Mono.Unix.UnixPath.GetCompleteRealPath(path.ToString())); |
Contributor
There was a problem hiding this comment.
GetCompleteRealPath is a method that will get the real link from a symlink?
| // osx terminal app doesn't inherit the PATH env var and there's no way to pass it in | ||
| var envVarFile = environment.FileSystem.GetRandomFileName(); | ||
| environment.FileSystem.WriteAllLines(envVarFile, new string[] { "cd $GHU_WORKINGDIR", "PATH=$GHU_FULLPATH:$PATH /bin/bash" }); | ||
| Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755) |
StanleyGoldman
previously approved these changes
Aug 15, 2017
StanleyGoldman
approved these changes
Aug 15, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #192
On non-windows, git and other files might be symlinks, so when we're using them as a base for determining parent directories, we may need to resolve the symlink first. The rules for automatically
doing symlink resolution are tricky, so for now just do it manually.
Still not happy with how we're finding git on the system, but this should at least make the command line work across all systems.
An existing problem right now is that OSX overwrites values set to the PATH env variable when it loadsThis is fixed now by creating a little shell script that in turn invokes bash with a proper environment./etc/profilein preparation to run bash, which is seriously screwed up on their part. That means that the opened command line won't have our path variable value (but it will have all the other env vars). I'm still investigating how to fix that...FYI, we want the GitExecutablePath to reflect where the binary was found, and the GitInstallPath to reflect where it is installed. When the binary is a symlink (like /usr/local/bin/git -> ../Cellar/git/2.12.2/bin/git), this means GitExecutablePath will have /usr/local/bin/git and GitInstallPath will have /usr/local/Cellar/git/2.12.2/bin