fix(sidekiq): update regexp for updating docker-compose.yml to properly match#596
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request updates the regular expression used for detecting the "services:" header in docker-compose.yml files.
- Updates the regex pattern to match a newline after "services:" instead of an impossible double quote.
- Fixes a bug where the previous regex never matched any content.
Comments suppressed due to low confidence (1)
variants/sidekiq/template.rb:40
- The updated regex assumes that 'services:' is immediately followed by a newline. Consider broadening the pattern to account for potential trailing whitespace or alternative line endings to ensure robust matching across different docker-compose.yml formats.
+", after: /^services:\n/
JacobBriggsAckama
approved these changes
Mar 20, 2025
eoinkelly
reviewed
Mar 20, 2025
| redis: | ||
| image: redis | ||
| ", after: /^services:$"/ | ||
| ", after: /^services:\n/ |
Contributor
There was a problem hiding this comment.
non-blocking: I usually prefer \A and \z as start and end delimiters in ruby regex because they don't change behaviour in multi-line strings
eoinkelly
approved these changes
Mar 20, 2025
lukeify
approved these changes
Mar 20, 2025
G-Rath
added a commit
that referenced
this pull request
Mar 27, 2025
The file manipulation methods provided by Thor don't stop execution when they fail to do the defined manipulation, instead in our case they print an error but then proceed; we actually want to error in this situation since the whole point of our template is to be applying our preferred practices meaning its moot if we don't... This really came into light with the Rails 8 upgrade which had a number of changes to the configuration files in particular that caused a number of our customizations to be skipped. By introducing bang versions of the methods that error if the file contents does not change, we can ensure going forward all manipulations actually work; this uses the same logic I introduced in #533 for `gsub_file`, and caught a bug that I fixed in #596
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current regexp will never work because it's expecting a double quote character after the end of the line, which is impossible for two reasons.
Instead, I've replaced both characters with a newline as that feels like a better match (though really in hindsight just removing the double quote probably would have been enough to fix this 😅)
Found via #595