There are several obvious ways to approach this:
## 1. PkgVersion takes full responsibility.
When emitting the $VERSION declaration, PkgVersion (if some boolean
option, like auto_underscore, is true) checks is_trial. If it's true,
and if $zilla->version does not match /_/, it tacks on "_0" and also
adds a second line, $VERSION = eval $VERSION.
This is nice and simple, and automatically affects everyone... but not
everything.
Basically, everything else checking $zilla->version still sees no
underscore. This is either a bug or a feature, depending on how you
define things, but I think it's a bug.
## 2. AutoVersion gets a new default
Right now, the default AutoVersion template ends with something like this:
{{$ENV{DEV} ? (sprintf '_%03u', $ENV{DEV}) : ''}}
We could extend that so that if ! $ENV{DEV} but is_trial, it appends _0
This is really really simple, which is nice, but it only helps if you're
using AutoVersion. It doesn't affect, say, Git::NextVersion.
## 3. Some very early plugin mutates $zilla->version
A plugin fairly early on in the life cycle of things looks at
$zilla->version and $zilla->is_trial; if is_trial and $version !~ /_/
then it mutates $zilla->version in place, before it affects anything else.
This "solves everything." But, of course, it doesn't work.
$zilla->version is populated by Dist::Zilla::_build_version, which flips
through the "version =" root dist.ini option and then all the
VersionProvider plugins. If there is exactly one answer, everything
works out. If there is more than one answer – i.e., you have a dist.ini
version AND a VersionProvider plugin offers a setting, or you have two
opinionated VersionProvider plugins – then an exception is thrown.
Initially there was some notion of adding a VersionMunger kind of
plugin, but we didn't do that.
We could still do this, by replacing the use of a builder for version
with some mechanism to build the version during BUILD differently.
VersionProviders could blindly set the version, clear it and re-set it,
or {set it if unset and die otherwise} mimicking the current behavior.
In this scenario, PkgVersion will still need a (presumably default true)
auto_eval option to add a second $V = eval $V line when the version
string contains an underscore. (Of course, it should probably have that
option now, too!)
--
rjbs