[Blueprints] Preserve the first char of all filenames sourced from GitDirectoryReference #2070
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.
Adjust GitDirectoryReference to stop cutting off the first character from each filename when the repository path starts with a slash.
Closes #2061
Closes #1999
Implementation
The problem was passing the wring prefix length to
fileName.substring()
(user input vs path without the leading slash). This PR adjusts that.In addition, it updates git-sparse-checkout.ts to use
commitHash
and not ref name for fetching files. This way you can checkout a specific commit, and that's convenient for testing and developers consuming the API.It also modified the CORS proxy to allow 'git-protocol' in headers.
Testing
Go to http://127.0.0.1:5400/website-server/#{%22landingPage%22:%22/wp-admin/%22,%22preferredVersions%22:{%22php%22:%227.4%22,%22wp%22:%225.9%22},%22steps%22:[{%22step%22:%22login%22,%22username%22:%22admin%22},{%22step%22:%22installPlugin%22,%22pluginData%22:{%22resource%22:%22git:directory%22,%22url%22:%22https://wordpress-playground-cors-proxy.net/cors-proxy.php?https://github.com/Automattic/page-optimize.git%22,%22ref%22:%22master%22,%22path%22:%22/%22},%22options%22:{%22activate%22:true,%22targetFolderName%22:%22page-optimize-from-git%22}}]} and confirm you see wp-admin (without CSS).