Skip to content

Implement when PreleaseLabel is empty, the PreleaseTag is generated correctly #3447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

HHobeck
Copy link
Contributor

@HHobeck HHobeck commented Mar 22, 2023

Fix [Bug] When PreleaseLabel is empty, the PreleaseTag is not correctly generated #2347

Close #2347

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@HHobeck HHobeck force-pushed the feature/2347_PromoteTagEvenIfNameIsEmpty branch 2 times, most recently from 5f11137 to 45ea2c0 Compare March 28, 2023 08:06
@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 28, 2023

I'm done please review and merge to main.

@arturcic
Copy link
Member

Is there any reason to have 4 new interfaces IContinuousDeliveryVersionCalculator, IContinuousDeploymentVersionCalculator, IManualDeploymentVersionCalculator, and ITrunkBasedVersionCalculator that have the same method with the same signature and to not share a IVersionCalculator?

If we take in consideration your suggestion regarding

public enum VersioningMode
{
    ManuallyDeployment, // previously ContinuousDelivery
    ContinuousDelivery, // previously ContinuousDeployment
    ContinuousDeployment, // new
    Trunkbased // previously Mainline??
}

I would rather have a IVersionCalculator that has the VersioningMode field and each implementation of this interfaces will set the appropriate VersioningMode andd then in the NextVersionCalculator I would inject all implementations and depending on the VersioningMode it will be selected the appropriate one. Thoughts?

@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 28, 2023

Is there any reason to have 4 new interfaces IContinuousDeliveryVersionCalculator, IContinuousDeploymentVersionCalculator, IManualDeploymentVersionCalculator, and ITrunkBasedVersionCalculator that have the same method with the same signature and to not share a IVersionCalculator?

If we take in consideration your suggestion regarding

public enum VersioningMode
{
    ManuallyDeployment, // previously ContinuousDelivery
    ContinuousDelivery, // previously ContinuousDeployment
    ContinuousDeployment, // new
    Trunkbased // previously Mainline??
}

I would rather have a IVersionCalculator that has the VersioningMode field and each implementation of this interfaces will set the appropriate VersioningMode andd then in the NextVersionCalculator I would inject all implementations and depending on the VersioningMode it will be selected the appropriate one. Thoughts?

Yep good point. At this moment I have separated the behavior which not aligns with the VersioningMode enumerator. But if we are going to decide to change it so we have a one to one relation then yes I think your idea is great.

Do you have something like this in mind?

public interface IVersionCalculator
{
    VersioningMode VersioningMode { get; }

    SemanticVersion Calculate(NextVersion nextVersion);
}

public IVersionCalculator GetSpecificVersionCalculator(VersioningMode versioningMode)
{
    return _serviceProvider.GetServices<IVersionCalculator>().Single(
        element => element.VersioningMode == versioningMode
    );
}

@arturcic
Copy link
Member

Is there any reason to have 4 new interfaces IContinuousDeliveryVersionCalculator, IContinuousDeploymentVersionCalculator, IManualDeploymentVersionCalculator, and ITrunkBasedVersionCalculator that have the same method with the same signature and to not share a IVersionCalculator?
If we take in consideration your suggestion regarding

public enum VersioningMode
{
    ManuallyDeployment, // previously ContinuousDelivery
    ContinuousDelivery, // previously ContinuousDeployment
    ContinuousDeployment, // new
    Trunkbased // previously Mainline??
}

I would rather have a IVersionCalculator that has the VersioningMode field and each implementation of this interfaces will set the appropriate VersioningMode andd then in the NextVersionCalculator I would inject all implementations and depending on the VersioningMode it will be selected the appropriate one. Thoughts?

Yep good point. At this moment I have separated the behavior which not aligns with the VersioningMode enumerator. But if we are going to decide to change it so we have a one to one relation then yes I think your idea is great.

Do you have something like this in mind?

public interface IVersionCalculator
{
    VersioningMode VersioningMode { get; }

    SemanticVersion Calculate(NextVersion nextVersion);
}

public IVersionCalculator GetSpecificVersionCalculator(VersioningMode versioningMode)
{
    return _serviceProvider.GetServices<IVersionCalculator>().Single(
        element => element.VersioningMode == versioningMode
    );
}

Exactly, in this case we don't need that many interfaces for the all the modes, and we have only the implementations and one interface

@arturcic
Copy link
Member

Exactly, in this case we don't need that many interfaces for the all the modes, and we have only the implementations and one interface

So what do you think @HHobeck should we make those changes to the VersionMode, or put that change into another PR?

@asbjornu
Copy link
Member

Exactly, in this case we don't need that many interfaces for the all the modes, and we have only the implementations and one interface

Agreed.

@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 29, 2023

Exactly, in this case we don't need that many interfaces for the all the modes, and we have only the implementations and one interface

So what do you think @HHobeck should we make those changes to the VersionMode, or put that change into another PR?

I think it is better to do this in a separate PR. You mentioned already to do this after the beta.2 release. Which is fine with me.

@HHobeck HHobeck force-pushed the feature/2347_PromoteTagEvenIfNameIsEmpty branch from 45ea2c0 to 263eb78 Compare March 29, 2023 05:49
@HHobeck
Copy link
Contributor Author

HHobeck commented Mar 29, 2023

Also we need to discuss the naming. IMO the naming of VersioningMode is missleading. Maybe a better name might be DeploymentMode. What do you think? In addition what do you like more Trunkbased or Mainline?

public enum DeploymentMode
{
    ManuallyDeployment, // previously ContinuousDelivery
    ContinuousDelivery, // previously ContinuousDeployment
    ContinuousDeployment, // new
    Trunkbased // previously Mainline??
}

@HHobeck HHobeck force-pushed the feature/2347_PromoteTagEvenIfNameIsEmpty branch from 263eb78 to 2ef39cd Compare March 29, 2023 15:13
@arturcic
Copy link
Member

@asbjornu do you agree with this PR to be merged?

@arturcic arturcic requested review from arturcic and asbjornu March 29, 2023 15:22
@HHobeck HHobeck force-pushed the feature/2347_PromoteTagEvenIfNameIsEmpty branch 2 times, most recently from 6d0edc6 to ae9cec8 Compare March 30, 2023 15:41
@HHobeck HHobeck force-pushed the feature/2347_PromoteTagEvenIfNameIsEmpty branch from 15a0970 to 7f7163c Compare April 6, 2023 06:28
Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great stuff. The only thing I'm a bit wary about is the change from 1.0.1+46 to 1.0.1-46 unless label is set to null. Not because the change doesn't make sense, I think it's a good default, but because it's a breaking change. However, I think we should test this change out in the community and see what feedback we get.

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of typos, then I think this is good.

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superb! 👏🏼

@arturcic arturcic merged commit 8caa9d2 into GitTools:main Apr 6, 2023
@mergify
Copy link
Contributor

mergify bot commented Apr 6, 2023

Thank you @HHobeck for your contribution!

@ddprince-pro
Copy link

ddprince-pro commented Jan 12, 2025

This is great stuff. The only thing I'm a bit wary about is the change from 1.0.1+46 to 1.0.1-46 unless label is set to null. Not because the change doesn't make sense, I think it's a good default, but because it's a breaking change. However, I think we should test this change out in the community and see what feedback we get.

@asbjornu I've been trying to make it so it doesn't output a prerelease number on my side, but setting "label" to null under GitVersion.yml doesn't work. This markdown file is also mentioning a similar solution, but still I can't figure it out: https://github.com/GitTools/GitVersion/blob/main/BREAKING_CHANGES.md.

image
Go that when applying the change:
image
"{BranchName}" is appended inside the "FullSemVer" variable.

When removing the label, I got that:
image

My configuration so far:
image

Would it be possible to help me so that I have for the variable FullSemVer, the value '1.0.0+37' instead of '1.0.0-37'?

My current gitversion:
image

Thanks in advance!

@asbjornu asbjornu deleted the feature/2347_PromoteTagEvenIfNameIsEmpty branch January 13, 2025 21:43
Copy link
Contributor

mergify bot commented Jan 13, 2025

Thank you @HHobeck for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] When PreleaseLabel is empty, the PreleaseTag is not correctly generated
4 participants