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

Test for empty subdir when searching for stacks #128

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

bodgit
Copy link
Contributor

@bodgit bodgit commented Mar 24, 2023

I was looking to see if it was possible to default the stack ID to an environment variable and found #60 but also found #125 had recently been merged so it should figure it out from the underlying cloned git repository. A new release hadn't been cut with this functionality so I tried building from source. I found spacectl still couldn't figure out the stack ID automatically.

All of my stacks map 1:1 with their own separate repository so the project root is unset. I found I needed to apply this small patch in order for the search to return any results.

Also, it currently always prompts me to pick the stack from the search results, even if there's only ever 1 stack returned. This looks to be caused by this condition:

if len(items) > 1 || forcePrompt {

forcePrompt is always true so it doesn't matter how many search results have been returned.

@tomasmik tomasmik self-requested a review July 20, 2023 12:00
@tomasmik
Copy link
Contributor

Sorry for the late reply.

Also, it currently always prompts me to pick the stack from the search results, even if there's only ever 1 stack returned. This looks to be caused by this condition

that is done on purpose, so you don't accidentally execute an action on a wrong stack. This PR however is alright and if you would solve the conflicts, I'm happy to approve it.

Only add the projectRoot condition if the subdir is non-nil and also not
an empty string, otherwise the search doesn't return any stacks.
@bodgit bodgit force-pushed the check-for-empty-string-subdir branch from 457a910 to 4456a96 Compare July 20, 2023 15:38
@bodgit
Copy link
Contributor Author

bodgit commented Jul 20, 2023

that is done on purpose, so you don't accidentally execute an action on a wrong stack.

It would be nice if there was a way to turn that off, either a flag or by setting an environment variable maybe?

This PR however is alright and if you would solve the conflicts, I'm happy to approve it.

Conflicts fixed.

@tomasmik
Copy link
Contributor

It would be nice if there was a way to turn that off, either a flag or by setting an environment variable maybe?

Feel free to open an issue for that.

@tomasmik tomasmik merged commit 35f7028 into spacelift-io:main Jul 25, 2023
8 checks passed
@bodgit bodgit deleted the check-for-empty-string-subdir branch July 25, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants