Rewrite the `fish` plugin from scratch
This plugin needed significant reworking. It now uses StringIO to construct the completion script and pathlib to manage paths uniformly. Functions now have type annotations and the flow of information through the entire script is much more readable.
More importantly, the actual contents of the script produced have been rewritten entirely. A more sophisticated parsing function is now used to determine when to show global option completions. Based on Fish's source code, a much more comprehensive string escaping function is now used to put data in the completion script. The completion for metadata values (as provided by --extravalues) actually works now: it needed to provide completions for the word the user was in the middle of typing (e.g. artist:ab -> artist:abba), rather than the word following.
- [x] Documentation
- [ ] Changelog
- [ ] Tests
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.
Fish's complete builtin offers a -C flag which lets you test what completions would be offered for a certain command-line; this could be used to perform automated testing. I suppose this is doable, by making any such tests conditional on a Fish executable being found. But I don't know whether that should be a separate PR or not. This one is already a complete rewrite of the plugin.
cc @Serene-Arc, this follows on from the small changes I made to fish.py in #5337. The more I looked at the code, the more I wanted to rewrite it.
I agree, a comprehensive testing solution is important. I was also concerned about the security of these sorts of shell scripts, but I hadn't thought about just comparing the results to a fixed script string in the tests -- I'll definitely implement that.
@Serene-Arc, I've implemented a basic file test, so there is some guarantee that the generated script will not contain malware. I can cover some more cases (e.g. using sample items from the library and checking the script with --extravalues) here, but I'd like to address them and an actual testing solution (where a Fish instance is launched and the generated script is tested) in a later PR. Let me know what you'd prefer.
@snejus, I know you were working on the testing infrastructure in #5362. I've ended up getting started on the pytest migration by defining some shared fixtures here, based on the code from your PR -- can you take a look (at beets/test/fixtures.py in particular) to make sure it all checks out? It can coexist with the existing testing infrastructure so we can migrate over time.
Sorry - my CLI has gone haywire and accidentally approved this PR 😅
no worries @snejus!
@snejus bump on review?
Ah sorry, completely missed out on this! Will have a look now!
It looks like the Windows builds are broken because of the reflink issue. @snejus, feel free to review anyway.
It looks like the Windows builds are broken because of the
reflinkissue. @snejus, feel free to review anyway.
You can now rebase as the fix has been merged upstream 🙂
Everything looks good - there's only one bit that's left, see https://github.com/beetbox/beets/pull/5359#pullrequestreview-2246989763. What did we decide to do about the test setup?
I'll implement it now, @snejus!
There seems to be some weird issue with test coverage. @snejus, any idea what's going on?
There seems to be some weird issue with test coverage. @snejus, any idea what's going on?
I have a feeling that's because the workflow is being run from your fork, where the environmental variable doesn't exist.
Try replacing pull_request with pull_request_target in .github/workflows/ci.yaml?
@bal-e sorry I didn't realise this was ready! If you rebase the PR off master the coverage should run fine now.
@snejus I tried pull_request_target, but it looks like that disabled CI checking for the PR entirely. Is there any good way to disable specifically the upload-coverage action for PRs?
@bal-e see #5479 where I did the same change which later got reverted since I discovered it indeed disabled PR checks 😅
Is there any good way to disable specifically the upload-coverage action for PRs?
Haven't yet looked into this... For now, I guess, you can ignore this failure
For the future PRs, note that since you're a member of the organization you can push your work directly to a branch in this repo (beetbox/beets) - this issue does not come up. That's what I've been doing myself.
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.