Rename a few metadata update helper classes#497
Conversation
That's an understandable goal 👍 But tbh iirc I think both You can find some more context for all of those in @mokagio post from last year about the state of those classes/actions [paaHJt-3fL-p2]. Given this, I wonder if we shouldn't use the opportunity of this PR to remove all of the implementations of this (in release-toolkit + any local implementation that might still be remaining in WPAndroid/WCAndroid repos) but one, and only keep the most recent one in (PS: See also the RFC for our future plans about replacing this action with a |
|
@AliSoftware That all sounds reasonable to me. I tried to look into the history of the localization project, but got overwhelmed by the amount of the information and unfamiliar territory like GlotPress. I think @mokagio has started to consolidate the two helper classes in #498. Beside, I think the PR—not having duplicated symbols—is an improvement on itself, right? We can resolve the duplicated symbols first, whilst looking into consolidating the two helpers. |
Issue
A few classes (
Fastlane::Helper::MetadataBlock& co.) with the same names are defined in two source files:metadata_update_helper.rbandan_metadata_update_helper.rb. That means when you use those classes, there really isn't any guarantee which implementation you'll get at runtime.Based on this
require an_metadata_update_helper.rbstatement, I think we would want to use the classes defined inan_metadata_update_helper.rbin thean_update_metadata_sourcefastlane action. But when running in Ruby 3, the classes (for exampleFastlane::Helper::UnknownMetadataBlock) used in that action aren't the ones defined in thean_metadata_update_helper.rbfile.You can reproduce this issue by inspect the class's source code location. First, make the following code changes locally.
Check out the trunk branch and run
bundle exec fastlane run an_update_metadata_source. You should see a similar output like this:Checkout branch
use-ruby-3.2.2and run the same command. You should see output like this:The result is, the code uses the same class, but different implementations get picked up at runtime.
Solution
There are probably some historical issues underneath that I'm not aware of. And based on some pending unit tests, there probably was a plan to address those issues.
This PR doesn't intend to address all the issues hidden behind the duplicated symbols though. This PR simply wants to fix the duplicated symbols, by adding an
Anprefix to the classes defined in thean_metadata_update_helper.rbfile.I have made a major assumption here. That is the
an_update_metadata_sourcefastlane action is the only one that uses the classes inan_metadata_update_helper.rb, which is why I only changed that one source file. It would be good to get a confirmation whether this assumption is correct.Failing unit tests
One unit test doesn't agree with my changes. There are two unexpected failures in
ios_update_metadata_source_spec.rbandgp_update_metadata_source_spec.rb(the failing test case is in theshared_examples_for_update_metadata_source_action.rbfile.)I don't think they fail because the changes are incorrect. My assumption is those unit tests were written incorrectly. You can do a similar test as above. First, making the following code changes:
Checkout the trunk branch and run
bundle exec rspec ./spec/ios_update_metadata_source_spec.rb. You should see output like this:That is obviously incorrect. The test case runs tests against
IosUpdateMetadataSourceAction, but with a class defined in an_ metadata_update_helper.rb.What I did was moving that failing test case to the
Fastlane::Actions::AnUpdateMetadataSourceActiontest case, because maybe the expectations in it don't apply to theios_andgp_ones. Again, I'm not familiar with po file generation logic. It'd be good to get a confirmation that this change is okay.Test Instructions
I'm not entirely sure how to test this, as I don't know much about what is a "po" file and how it should be generated. I'm happy to carry out some testing if you have any suggestions.
Question
Should this change be a breaking change? The class name changes are a breaking changes, but I'm not sure if they are used outside of this library. The apps should use the actions, not the helper classes, correct?
Checklist before requesting a review
bundle exec rubocopto test for code style violations and recommendationsspecs/*_spec.rb) if applicablebundle exec rspecto run the whole test suite and ensure all your tests passCHANGELOG.mdfile to describe your changes under the appropriate existing###subsection of the existing## Trunksection.MIGRATION.mdfile to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.