Skip to content

Conversation

@iangmaia
Copy link
Contributor

@iangmaia iangmaia commented Aug 4, 2025

What does it do?

This PR adds to the DerivedBuildCodeFormatter class the possibility to configure a variable number of digits per version components, so that we have more flexibility to increase the maximum number of builds per a specific major / minor version, for example.

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations.
  • Add Unit Tests (aka specs/*_spec.rb) if applicable.
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass.
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.

@iangmaia iangmaia self-assigned this Aug 4, 2025
@iangmaia iangmaia added the enhancement New feature or request label Aug 4, 2025
@iangmaia iangmaia force-pushed the iangmaia/derived-build-formatter-var-digits branch from 0a9e9e0 to 09e71f9 Compare August 4, 2025 17:00
@iangmaia iangmaia marked this pull request as ready for review August 4, 2025 17:07
@iangmaia iangmaia requested review from a team and AliSoftware August 4, 2025 17:09
@iangmaia iangmaia changed the title Add components digits configuration to DerivedBuildCodeFormatter Add version components digits configuration to DerivedBuildCodeFormatter Aug 4, 2025
Base automatically changed from iangmaia/derived-build-formatter-enhancements to trunk August 4, 2025 18:48
@iangmaia iangmaia requested a review from AliSoftware August 5, 2025 13:39
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Mostly 💄 nitpicks + some suggestions to improve the unit tests. Otherwise LGTM 👍

@iangmaia
Copy link
Contributor Author

iangmaia commented Aug 5, 2025

@AliSoftware I believe I addressed all the test suggestions!

@iangmaia iangmaia requested a review from AliSoftware August 5, 2025 19:46
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Just nitpicks to fix code comments, otherwise LGTM so approving to unblock you

Comment on lines 62 to 67
def validate_prefix!(prefix)
unless prefix.nil? || prefix.is_a?(String) || prefix.is_a?(Integer)
UI.user_error!("Prefix must be a string or integer, got: #{prefix.class}")
end

prefix_str = prefix.to_s
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Today I re-learned that nil.to_s returns the '' empty string (as opposed to crashing).

This is why even if now you call validate_prefix! from the def initialize without doing the prefix ||= '' anymore first, this prefix_str = prefix.to_s still doesn't crash 👍


describe 'digit count validation' do
# Generate all combinations of [1,2,3] for each of the 4 digit count parameters
all_digit_combinations = Array.new(4, [1, 2, 3]).reduce(&:product).map(&:flatten)
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 I'm surprised that rubocop doesn't complain about you using a local variable here instead of using RSpec's let(:all_digit_combinations) { … } syntax (which I believed was more idiomatic to Rspec)…

I don't mind either approach in practice (should do the same in the end, maybe except some memoizing of the value when using let?). I just wouldn't want a rubocop warning to appear because of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I did it first with a let, but had to re-learn that it won't work if we use it as part of the context:

  `all_digit_combinations` is not available on an example group (e.g. a `describe` or `context` block). It is only available from within individual examples (e.g. `it` blocks) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc).

iangmaia and others added 3 commits August 5, 2025 22:26
Co-authored-by: Olivier Halligon <[email protected]>
Co-authored-by: Olivier Halligon <[email protected]>
@iangmaia iangmaia merged commit 6fa277e into trunk Aug 5, 2025
6 checks passed
@iangmaia iangmaia deleted the iangmaia/derived-build-formatter-var-digits branch August 5, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants