Skip to content

[Bug] The configuration JSON schemas use the wrong properties for default values and assign bad regex patterns #3739

@BinToss

Description

@BinToss

Describe the bug

Some properties in GitVersion.configuration.json are used for the wrong purpose (pattern where default should be used) or are assigned bad values (human-readable date-time formats are assigned to regex-only fields).

Were these mistakes made by a schema generator?

image

Definitions using pattern when they shouldn't, assign literal strings with no regex syntax, or are annotated with the wrong type(s):

  • pattern regex string which must resolve to a DateTime object. This makes no sense. In the first place, this string must be usable as a parameter for System.Runtime.Serialization.DateTimeFormat(string formatString).
    • commit-date-format
  • pattern regex string is optionally used for asserting the property's value. The default annotation should be used instead.
    • major-version-bump-message
    • minor-version-bump-message
    • no-bump-message
    • patch-version-bump-message
    • tag-number-pattern (only in 5.12 config schema)

See this branch for manual changes

RFC 3339 Max Value (no offset): 9999-12-31t23:59:59z
RFC 3339 Min Value (no offset): 0000-01-01t00:00:00z

RedHat's vscode-yaml somehow follows RFC 3339's spec. It includes case-insensitivity for the 't' and `z' (both of which are mandatory) and can process the various acceptable formats for the optional offset numbers.

Expected Behavior

The *-version-bump-message fields should...
...not use the pattern property expect any regex string and use the default annotation field.

Actual Behavior

The *-version-bump-message fields expect regex-like values which perfectly match the regex pattern in the pattern field which is currently set the default values of each field.
If the fields' values are different than the default values, YAML/JSON validators declare it an error.

Possible Fix

scratch that. I'm making a PR. While fixing the pattern-default issues, I discovered the regex patterns for date-time fields are useless.

"major-version-bump-message": {
"format": "regex",
"pattern": "\u0027\\\u002Bsemver:\\s?(breaking|major)\u0027",
"description": "The regular expression to match commit messages with to perform a major version increment. Default set to \u0027\\\u002Bsemver:\\s?(breaking|major)\u0027",
"type": "string"
},

    "major-version-bump-message": {
      "format": "regex",
-      "pattern": "\u0027\\\u002Bsemver:\\s?(breaking|major)\u0027",
+      "default": "\u0027\\\u002Bsemver:\\s?(breaking|major)\u0027",
      "description": "The regular expression to match commit messages with to perform a major version increment. Default set to \u0027\\\u002Bsemver:\\s?(breaking|major)\u0027",
      "type": "string"
    },

"minor-version-bump-message": {
"format": "regex",
"pattern": "\u0027\\\u002Bsemver:\\s?(feature|minor)\u0027",
"description": "The regular expression to match commit messages with to perform a minor version increment. Default set to \u0027\\\u002Bsemver:\\s?(feature|minor)\u0027",
"type": "string"
},

    "minor-version-bump-message": {
      "format": "regex",
-      "pattern": "\u0027\\\u002Bsemver:\\s?(feature|minor)\u0027",
+      "default": "\u0027\\\u002Bsemver:\\s?(feature|minor)\u0027",
      "description": "The regular expression to match commit messages with to perform a minor version increment. Default set to \u0027\\\u002Bsemver:\\s?(feature|minor)\u0027",
      "type": "string"
    },

Steps to Reproduce

In an editor with JSON/YAML validation (e.g. VSCode), create GitVersion.yml and write minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:" to it.

winget install Microsoft.VisualStudioCode # install Visual Studio Code, then...
start 'vscode:extension/redhat.vscode-yaml' # install YAML Language Server extension
'minor-version-bump-message: "^(feat)(\\([\\w\\s-]*\\))?:"' > GitVersion.yml
code ./GitVersion.yml
# 'trust workspace' to allow the yaml extension to run

Context

VSCode complains that custom version bump message patterns don't match the "required" patterns for their respective fields.

Your Environment

  • Operating System: Windows 11 Pro Version 22H2 (OS Build 22621.2428)
  • VSCode: ["1.83.1", "f1b07bd25dfad64b0167beb15359ae573aecd2cc", "x64"]
  • redhat.vscode-yaml: 1.14.0
  • GitVersion.MSBuild: 6.0.0-beta.3
  • GitVersion.configuration.json: 6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions