Skip to content

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Dec 10, 2024

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).

…tDirectoryReference Adjust GitDirectoryReference to stop cutting off the first character from each filename when the repository path starts with a slash. Closes #2061 ## 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. 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).
@adamziel adamziel force-pushed the git-directory-resource-lacking-first-letters branch from 8dc4ed5 to 9865e5e Compare December 11, 2024 15:34
@adamziel adamziel merged commit 00a4433 into trunk Dec 11, 2024
9 of 10 checks passed
@adamziel adamziel deleted the git-directory-resource-lacking-first-letters branch December 11, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant