c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.06k stars 134 forks source link

Support for segment aliases? #178

Open bsolomon1124 opened 3 years ago

bsolomon1124 commented 3 years ago

From PEP 440:

Pre-releases allow the additional spellings of alpha, beta, c, pre, and preview for a, b, rc, rc, and rc respectively. This allows versions such as 1.1alpha1, 1.1beta2, or 1.1c3 which normalize to 1.1a1, 1.1b2, and 1.1rc3. In every case the additional spelling should be considered equivalent to their normal forms.

In other words, here:

in this scheme.

I realize bump2version is not designed to cater to PEP440's schema, per se, but this concept of aliasing certain parts (rather than requiring that values is sequential) extends to other slightly different schemes also.

I have a half-baked feature branch that partially implements the ability to specify aliases in bumpversion values config. For instance, it allows

values = 
  dev
  alpha,a
  beta,b
  rc,c

What I have actually found challenging, because there is a good deal of ambiguity involved, is how optional_value and first_value would need to be/allowed to be specified.

Questions for @c4urself and @ekohl

It would come down to something like setting section_config["values"] in cli.py to have some list/tuple elements rather than just str, with some corresponding changes in version_part.py and functions.py.

florisla commented 3 years ago

Do you have other examples of part aliases (outside of PEP440)?

bsolomon1124 commented 3 years ago

Do you have other examples of part aliases (outside of PEP440)?

One example shows that Maven also allows this.

the "alpha", "beta" and "milestone" qualifiers can respectively be shortened to "a", "b" and "m" when directly followed by a number.

Googling for examples is a little tricky, but I have a hunch aliasing occurs with node projects also.

florisla commented 3 years ago
* Does there seem to be any more intuitive way to allow the user to specify aliases versus the example shown above?

You could consider leaving values as-is showing the canonical (or preferred) names, and introducing another keyword aliases.

values = 
  dev
  alpha
  beta
  rc
aliases =
  alpha: a, alph
  beta: b
  rc: r, gamma
  dev: d
bsolomon1124 commented 3 years ago

@florisla I like that idea; it seems cleaner than the messy business of picking a separator for values.

florisla commented 3 years ago

I have a half-baked feature branch that partially implements the ability to specify aliases in bumpversion values config.

Do you support serializing with aliases as well?

If you only care about parsing the aliases, then bump2version will never put an alias in a file? You would need to manually edit the version to introduce them, and they would disappear on the next bump.

Edit: just found #174, which might be relevant for context.