-
Notifications
You must be signed in to change notification settings - Fork 165
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
[#1546] RepoCloner: fix local repos relative pathing and spaces #1562
[#1546] RepoCloner: fix local repos relative pathing and spaces #1562
Conversation
8ca899e
to
a36025a
Compare
Hi @dcshzj, I would like advice regarding the following issues.
|
Also related is a suggestion to create some kind of |
Looks okay to me. Your PR just happens to touch files that were not previously covered by tests, so it should be fine. We can go as far as testing the string outputs, but that should be in a separate PR.
For this, the methods mainly pertain to shallow cloning and the tests should be covered in the system tests under
It does seem like the only way to me, so it should be fine.
I doubt issue #442 would be resolved so soon, so it is fine to proceed with the assumption that we are keeping to the current way of forming Git commands. However, I am not sure about the utility of having a GitCommandBuilder, as currently we are only solving the issue of adding quotation marks around paths and removing backslashes. There are many Git commands that we use, and each of them have many more possible options, which may cause a GitCommandBuilder file to get too big quickly. An ideal case is that we would have tests to catch such issues, but even without it, the many Nonetheless, I appreciate the suggestion! It is great to hear new ideas and discuss them, and the project benefits from such fresh perspectives. |
f539c42
to
a36025a
Compare
@dcshzj Ready for review. Added an additional paragraph in the OP "Due to how..." to explain the changes in addressing a peculiar issue faced with paths with trailing backslashes. Besides that, I have been unable to replicate the issue with the trailing backslash on the master branch (the issue mentioned above is due to adding quotation marks to handle spaces in paths, something which is not present in the master branch) so it has been left out of the commit message unless there is an update. |
Requesting a review for this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One question before I approve.
@@ -22,4 +31,17 @@ public void repoCloner_emptyRepo_failsGracefully() throws Exception { | |||
|
|||
Assert.assertNull(clonedRepoLocation); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any test for nonEmptyRepo but an invalid path for any file or folder? Or will all repos fall only in these two categories -> empty and nonEmpty with everything right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not too sure of this. I can see some issues where a linux repo might cause some path issues when cloned into a windows computer. But otherwise, I am not sure how this can occur since the list of files is obtained with a git command which should also be there if it was cloned successfully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tejas2805 Any updates regarding this?
Link below provides a more accurate file diff as merging with current master seems to have caused merged changes to show up in the file diff. |
@fzdy1914 Requesting a review as it has gotten the initial approval. |
Fixes #1546
For relative paths, the issues lies in
RepoCloner
's various process spawning methods. While the local repository's location is correctly verified in theRepoLocation
class, the subsequent processes spawned have their root path changed resulting in--repo
arguments with relative pathing to fail. This PR addresses this by adjusting the root path back to the user directory and the output directory is changed to account for this. Related methods with this issue have also been updated.For paths containing spaces, the issue comes from the reconstruction of the Path objects into a string to be executed as a command. While local repos with paths containing spaces (when inside quotation marks) are accepted initially when executing the jar file, the program will fail to clone them. This is fixed by adding quotation marks to the various git clone commands that accept paths.
GitClone::cloneBare
's output path has been altered to matchGitClone::cloneBareAsync
's logic more closely. At present,cloneBare
's actual output folder is relative to the location specified in the config file. It is difficult to specify an exact output directory for a repo to be cloned to. This is necessary for the test case that I have written.Due to how commands are reconstructed as strings to be ran on CMD in windows, there is a particular issue with repo paths with trailing backslashes that arises from placing paths in quotation marks. Taken from https://ss64.com/nt/syntax-esc.html:
As such, there is a need to remove trailing backslashes for paths on windows computers.
Commit message: