Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Skip hidden directories when creating commands #6081

Conversation

GuySartorelli
Copy link
Collaborator

@GuySartorelli GuySartorelli commented Apr 11, 2024

The Issue

DDEV thinks hidden directories in ~/.ddev/commands/ hold commands for services with names that start with a .

This can result in commands like this showing up:

Screenshot from 2024-04-11 17-53-05

Note that the composer.lock, composer.json, and config.yml files all live in a hidden directory.

(For reference, .php-utils/ here contains code and dependencies that my global host commands share - see https://github.com/GuySartorelli/my-ddev-commands if you're curious)

How This PR Solves The Issue

Skips hidden directories, so that files in those directories are not treated like commands.

Manual Testing Instructions

Add a hidden directory in ~/.ddev/commands/ with some files in it and run ddev - before the PR they will show up in the commands list, but afterwards they shouldn't.

Automated Testing Overview

Tests that a command in a hidden directory doesn't show in the commands list

Related Issue Link(s)

N/A

Release/Deployment Notes

In the very unlikely scenario where someone does actually have a service where the name of the services starts with a ., they will no longer be able to add global commands for it. That strikes me as exceedingly unlikely though.

@GuySartorelli GuySartorelli requested a review from a team as a code owner April 11, 2024 06:04
@GuySartorelli GuySartorelli force-pushed the 20240411_GuySartorelli_skip-hidden-dirs-in-commands-dir branch from da3e0d3 to 743b90b Compare April 11, 2024 06:05
@GuySartorelli
Copy link
Collaborator Author

If this is at all controversial I can live with moving my directory .phputils directory into commands/host/.phputils instead since that will be ignored - but this seems like something someone else will eventually run into as well so I figured I'd offer up this solution first.

@rfay
Copy link
Member

rfay commented Apr 11, 2024

So you use directories named .something in your ~/.ddev/commands directory? What are they for?

I think it's totally reasonable to skip hidden directories, but interested in how you ended up here.

@GuySartorelli
Copy link
Collaborator Author

So you use directories named .something in your ~/.ddev/commands directory? What are they for?

It's right in the PR description. :p

(For reference, .php-utils/ here contains code and dependencies that my global host commands share - see https://github.com/GuySartorelli/my-ddev-commands if you're curious)

@rfay
Copy link
Member

rfay commented Apr 11, 2024

It would be nice to come up with a standardized way for commands to share libraries. We got stuck on this with the launch refactoring.

@GuySartorelli
Copy link
Collaborator Author

GuySartorelli commented Apr 11, 2024

I don't think we did get stuck - I mentioned an approach in that PR but the implementors decided to go with a different approach.
xhprof and xdebug for example have a function which is defined elsewhere. For any bash commands provided by DDEV we can do the same thing to provide any manner of utility scripts that can be shared across commands.

For custom commands outside the DDEV codebase that obviously won't be as helpful - maybe it's worth opening an issue about that.

In any case the scope of this PR is intentionally very narrow to fix what I perceive to be a bug with how hidden directories in the ~/.ddev/commands/ directory are treated.

@rfay rfay requested a review from stasadev April 29, 2024 14:15
Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, it looks good to me 👍

@rfay rfay added this to the v1.23.1 milestone May 3, 2024
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! There's only one problem that I see... changing the code for exactly one dev's workflow :) But that one person is a valued contributor, so thanks! And thanks for checking the test coverage while you were there.

@GuySartorelli
Copy link
Collaborator Author

changing the code for exactly one dev's workflow

One developer's workflow today ;p Fixing small issues like this can reduce friction for others to do similar things if they want to.

@rfay rfay merged commit 4521979 into ddev:master May 15, 2024
24 checks passed
@GuySartorelli GuySartorelli deleted the 20240411_GuySartorelli_skip-hidden-dirs-in-commands-dir branch May 15, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants