Work around a bug in DottedVersion.compare_to.
Work around a bug in DottedVersion.compare_to.

It appears that the comparator erroneously reports that `10.0.0.10A255 >= 10.2.0.10E125`; the problem is in the handling of the last component. To avoid this, we trim the version number down to at most three components until the bug is fixed.

RELNOTES: None.
PiperOrigin-RevId: 244975722

bazelbuild/rules_swift,bazelbuild/rules_swift