wp-cli / dist-archive-command

Create a distribution .zip or .tar.gz based on a plugin or theme's .distignore file
https://developer.wordpress.org/cli/commands/dist-archive/
MIT License
48 stars 24 forks source link

Tests for 47. Allow for leading slashes in .distignore #58

Closed BrianHenryIE closed 2 years ago

BrianHenryIE commented 2 years ago

Example project:

test.php
maybe-ignore-me.txt
test-dir/maybe-ignore-me.txt
test-dir/foo/maybe-ignore-me.txt

with example .distignore:

/maybe-ignore-me.txt

Should archive:

test.php
test-dir/maybe-ignore-me.txt
test-dir/foo/maybe-ignore-me.txt

This is working for zip.

The tests are failing for tar, but when I echo the tar command that is being used and manually cd to the directory and paste and run it, it works.

Could someone please take a look and see if they can make sense of why it's not working? I'm guessing it's related to the current working directory being somehow affected inside WP_CLI::launch().

@markjaquith

BrianHenryIE commented 2 years ago

Tests are now passing on MacOS but not on GitHub Actions.

The problem was that PHP's escapeshellcmd() was escaping the ^ used in the exclude rule to tie the path to the root.

I've added a function to permit exceptions in escapeshellcmd().

I'll have to set up Ubuntu locally and run the tests there. I'll use nektos/act.

BrianHenryIE commented 2 years ago

It seems sys_get_temp_dir() was being shared across multiple test Examples, so files already existed as subsequent tests were run. This scenario is not possible when running the command from CLI wp dist-archive ....

There's a new test failure now! I have a feeling #59 will solve it. I'll work on the PR now.

danielbachhuber commented 2 years ago

Ship #61