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
Fix for files/folders created at pwd by New-Item when given path is drive root (#5228) #6584
Conversation
Running the tests in question that are failing seem to be failing both on the current preview build (6.1.0-preview.1) and my build. I can't determine if this is a breaking change, |
For now, I will leave this as ready to merge and non-breaking until review. |
Confirmed that this broke Get-ChildItem when |
@mcbobke Feel free to ask if you need help. |
I've been working on a different solution and am currently testing it before I commit. Thanks for the encouragement, I will definitely be asking some questions once it's up! |
Alright, I think I'm on the right track this time. Because the argument for Testing for an empty path after Looking forward to review. |
@mcbobke The PR contains alien commits. I suggest you to rebase and squash before we start review. |
@iSazonov I did my best to clean up the commit history; is there anything I can do to clean it up further? |
@mcbobke I still see an alien commit https://github.com/PowerShell/PowerShell/pull/6584/commits |
Whoops! Apologies. Looks like it's fixed now. |
@mcbobke No, your commit contains unrelated code. I see you make the PR from forked master branch. You should create new branch for every new work.
|
Understood @iSazonov . How should I branch this work off now that it's in master? Reset to previous commit, create new branch, push changes to new branch? |
If you haven't experience with git you could simply backup your code (copy files) and re-create your fork, create new branch and copy your files (or changed code blocks) back. |
I have some experience with Git, but I have learned some things while working on this change. :P Does that mean I need to recreate the PR as well? I can revert the commit and branch it off, if I can also edit the PR. Otherwise, I'd create a new one. |
You are free to choose a way. |
Okay, what I'll do then is branch off and create a new PR and reference this one. Thanks for all of your help, this has been a learning experience! |
@mcbobke If our docs is not clear for the repo newbies please feel free to commit additions with your experience. |
That's a really good idea. I will look through and see where I can add some clarification. |
PR Summary
If the
Path
argument toNew-Item
is the root of a drive such asC:\
, the LocationGlobber attempts to generate a drive root relative path from the pathC:
.GetDriveRootRelativePathFromPSPath
determines that this is an absolute path, and strips the drive name and colon from the path; originally, this would result inGenerateRelativePath
determining that the current working directory should be given as the relative path. Now, a check is made on whether stripping the drive name and colon results in an empty string; if it does, the root of the current PSDrivecontext.Drive.Root
is returned as the relative path.This fixes #5228.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.[feature]
if the change is significant or affects feature tests