batches: encourage semver that prerelease versions are newer
Created by: courier-new
This is a partial fix for the issue Malo was running into when trying to execute a batch spec with src-cli on demo.sourcegraph.com despite having user.name
and user.email
set in his git config:
❌ Error:
{
"message": "3 errors occurred:\n\t* Must validate one and only one schema (oneOf)\n\t* commits.0: authorName is required\n\t* commits.0: authorEmail is required\n\n",
"path": [
"createChangesetSpec"
]
}
I thought, and we say in the docs, that
The commits created from your spec will use the git config values for
user.name
anduser.email
from your local environment
but I couldn't actually find if/how this happening in the code. In BuildChangesetSpecs
, we explicitly only check the changeset template from the input spec, and the closest I could find to us actually looking at the git config is where we pull from these values to pre-populate them in the batch spec file for src batch new
. So maybe this isn't actually correct.
Regardless of whether or not we do pull from the local git config, the point still remains that we should be falling back on [email protected] and "Sourcegraph", so the error Malo ran into is still out of place.
In a strange turn of events, I was able to trace this to the feature flag IncludeAutoAuthorDetails
. It turns out that the version currently on demo (3.35.1-rc.3) is not considered by semver to pass the constraint we have for this feature flag (">= 3.20.0") due to the prerelease part (-rc.3), so the lack of author and email specified in the batch spec would actually fail the schema validation since the feature to use the fallbacks is not turned on.
The "fix" in this case is to reassure semver that 3.35.1-rc.3 does, in fact, satisfy the constraint ">= 3.20.0", by telling it to actually evaluate and consider prerelease versions by including the minimum possible prerelease version suffix on the constraint: ">= 3.20.0-0", as it suggests in their docs.
I tested and ensured that the constraint is still satisfied by versions without a prerelease, as before (e.g. 3.35.1 also still passes the check).