Skip to content

[Bug] Tag: useBranchName isn't working in some cases #2201

@zhuravelsv

Description

@zhuravelsv

Describe the bug
I faced issue with property "tag: useBranchName", I'm trying to use it, but it's not working in some cases, for example even if I use tag "tag.{BranchName}" I got "FullSemVer":"3.0.0-tag..1+8".

I'm not sure is it bug or not, but all details below

Configuration:

assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{InformationalVersion}'
tag-prefix: '[vV]'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
commit-message-incrementing: Disabled
continuous-delivery-fallback-tag: prerelease
branches:
  master:
    regex: ^master
    mode: ContinuousDelivery
    tag: useBranchName
    increment: None
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
  feature:
    regex: .*
    mode: ContinuousDelivery
    tag: useBranchName
    increment: None
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false

Expected Behavior

master - tag is "master"
custom/foo - tag is "foo"
foo - tag is "foo"
feature/name - tag is "name"
feature - tag is "feature"

Actual Behavior

Tag: useBranchName isn't working for master branch and some other branches:
master, custom/foo, foo, feature/name, feature - no tag
(
useBranchName: "FullSemVer":"3.0.0+16",
tag.{BranchName}: "FullSemVer":"3.0.0+16",
tag.{BranchName}: "FullSemVer":"3.0.0-tag..1+16" (if we set tag: tag.{BranchName})
)

But, if we change regex in feature branch config to this "^features?[/-]" it will work because of this:
http://regexstorm.net/tester?p=%5efeatures%3f%5b%2f-%5d&i=features%2ffoo
regex cut all matched part, and remnants are used for tag, but if we configure regex to match all branches (like in case above) it will not work correctly

Context

I would like to add branch name tag to any branch (except master)

Possible Fix

BaseVersionCalculator.GetBaseVersion return incorrect version

Steps to Reproduce

Just try to use "useBranchName" or "{BranchName}" in master or configure to match all branch names

Your Environment

Azure devops (pipelines, nuget/artifacts), nect core 3.1

  • Version Used: 5.2.4
  • Operating System and version (Windows 10, Ubuntu 18.04): Ubuntu 18.04

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