-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitDirectoryResource: Accept "/", "", "." as root paths (#1860)
GitDirectoryResource was merged in #1858. Unfortunately, it didn't provide an easy way of saying "checkout all the files from the repo". This PR adds support for three root path syntaxes: * `"path": "/"` * `"path": "."` * `"path": ""` ## Testing instructions Run this Blueprint locally and confirm it installs the blocky formats plugin: ```json { "$schema": "https://playground.wordpress.net/blueprint-schema.json", "login": true, "landingPage": "/wp-admin/", "steps": [ { "step": "installPlugin", "pluginData": { "resource": "git:directory", "url": "https://github.com/dmsnell/blocky-formats.git", "ref": "trunk", "path": "/" } } ] } ```
- Loading branch information
Showing
3 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import { FileTree } from './git-sparse-checkout'; | ||
import { listDescendantFiles } from './paths'; | ||
|
||
const testTree: FileTree[] = [ | ||
{ | ||
name: 'packages', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'playground', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'storage', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'package.json', | ||
type: 'file', | ||
}, | ||
{ | ||
name: 'STORAGE_README.md', | ||
type: 'file', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'php-wasm', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'package.json', | ||
type: 'file', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'wordpress', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'wp-content', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'plugins', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'blocky-formats', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'block.json', | ||
type: 'file', | ||
}, | ||
{ | ||
name: 'index.php', | ||
type: 'file', | ||
}, | ||
{ | ||
name: 'README.md', | ||
type: 'file', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'index.php', | ||
type: 'file', | ||
}, | ||
{ | ||
name: 'wp-includes', | ||
type: 'folder', | ||
children: [ | ||
{ | ||
name: 'version.php', | ||
type: 'file', | ||
}, | ||
], | ||
}, | ||
{ | ||
name: 'wp-config.php', | ||
type: 'file', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
describe('listDescendantFiles', () => { | ||
it('should list all the descendant files from a subdirectory of a file tree', async () => { | ||
const files = listDescendantFiles(testTree, 'packages/playground'); | ||
expect(files).toEqual( | ||
expect.arrayContaining([ | ||
'packages/playground/storage/package.json', | ||
'packages/playground/storage/STORAGE_README.md', | ||
]) | ||
); | ||
}); | ||
it.each(['.', '/', ''])( | ||
'should list all the descendant files when "%s" is passed as path', | ||
async (path: string) => { | ||
const files = listDescendantFiles( | ||
[ | ||
{ | ||
name: 'index.php', | ||
type: 'file', | ||
}, | ||
], | ||
path | ||
); | ||
expect(files).toEqual(expect.arrayContaining(['index.php'])); | ||
} | ||
); | ||
}); |
This file contains 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