GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

Fix closing pull request from hotfix to support failed to inherit Increment branch configuration

Open micdenny opened this issue 2 years ago • 12 comments

Description

Changed the public method ExcludingBranches of IRepositoryStore adding an optional parameter bool excludeRemotes = false, it this way it should be backward compatible, actual calls to it like in MergeCommitFinder remains with the same behaviour, instead the call we did on BranchConfigurationCalculator in the InheritBranchConfiguration method, can be called passing excludeRemotes: true and this fixes the bug well explained in the issue.

Unfortunately this is a breaking change because I've changed a public api, even if we add a separated method, would break who is inherits from RepositoryStore or implement IRepositoryStore.

If you have a better idea, or a better name for excludeRemotes you're welcome to suggest.

Related Issue

Fixes #3020

Motivation and Context

It solves a problem with the calculation of the inherits gitversion increment strategy.

How Has This Been Tested?

You can check the integration tests I've added in the solution called Issue3020FailedToInherit, and it is welcome suggestion on better names and position of the file.

Screenshots (if appropriate):

Checklist:

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

micdenny avatar Sep 13 '22 10:09 micdenny

Please run dotnet format on your code

Sorry if I didn't run it, I read the contributing guidelines but the command was for old dotnet format, sdk 6 now has slightly different options, so I followed the vs2022 that should follow the editorconfig, in fact now running a simple dotnet format using the latest sdk 6.x it ~doesn't complain or change anything~ does have fixed a couple of spaces (dotnet format version 6.4.336403+6432a853ebcf4310b628187a215a65c59d9ecdf4).

I think this part of the CONTRIBUTING guidelines should be revised, because now everybody has installed sdk 6 and dotnet format it's embedded and has slightly different options:

image

probably a simple command like the follow should do the same:

dotnet format --exclude **/AddFormats/

micdenny avatar Sep 13 '22 11:09 micdenny

using the latest sdk 6.x it doesn't complain or change anything

I was wrong saying that it didn't change anything, because in fact has fixed a couple of space

micdenny avatar Sep 13 '22 11:09 micdenny

Hello @micdenny, Do you think your PR should fix this use case ?

[Test]
public void CalculatesCorrectVersionWhenPullRequestHotfixBranchToMain()
{
    using var fixture = new EmptyRepositoryFixture();
    fixture.Repository.MakeATaggedCommit("0.1.0");
    Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("develop"));
    fixture.Repository.MakeACommit();

    Commands.Checkout(fixture.Repository, "main");

    Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("hotfix/0.1.1"));
    fixture.Repository.MakeACommit();
    fixture.AssertFullSemver("0.1.1-beta.1+1");

    fixture.Repository.CreatePullRequestRef("hotfix/0.1.1", MainBranch, normalise: true);

    fixture.AssertFullSemver("0.1.1-PullRequest0002.2");
}

NightFox7 avatar Sep 13 '22 12:09 NightFox7

Hello @micdenny, Do you think your PR should fix this use case ?

@NightFox7 I'm going to try it adding it to this branch and pushing run :)

hold on ⏳

micdenny avatar Sep 13 '22 13:09 micdenny

@asbjornu some CI test are failing but I don't understand why:

image

micdenny avatar Sep 13 '22 13:09 micdenny

Hello @micdenny, Do you think your PR should fix this use case ?

@NightFox7 unfortunately it does not solve that problem 😞

Message: 
Shouldly.ShouldAssertException : variables.FullSemVer
    should be
"0.1.1-PullRequest0002.2"
    but was
"0.2.0-PullRequest0002.2"
    difference

This PR solves problems when there is also a remote in a local repo

micdenny avatar Sep 13 '22 13:09 micdenny

Hello @micdenny, Do you think your PR should fix this use case ?

[Test]
public void CalculatesCorrectVersionWhenPullRequestHotfixBranchToMain()
{
    using var fixture = new EmptyRepositoryFixture();
    fixture.Repository.MakeATaggedCommit("0.1.0");
    Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("develop"));
    fixture.Repository.MakeACommit();

    Commands.Checkout(fixture.Repository, "main");

    Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("hotfix/0.1.1"));
    fixture.Repository.MakeACommit();
    fixture.AssertFullSemver("0.1.1-beta.1+1");

    fixture.Repository.CreatePullRequestRef("hotfix/0.1.1", MainBranch, normalise: true);

    fixture.AssertFullSemver("0.1.1-PullRequest0002.2");
}

I'ts working here. ;) Do you have a bug or issue number?

HHobeck avatar Sep 18 '22 19:09 HHobeck

Yes ! @HHobeck Thank you. We just have to merge your PR then ;)

NightFox7 avatar Sep 20 '22 08:09 NightFox7

@asbjornu I've closed all the proposed changes, are you happy with this PR?

I don't understand what some tests are complaining about:

unknown test file type for 'artifacts/test-results/GitVersion.MsBuild.Tests.netcoreapp3.1.results.xml'

micdenny avatar Sep 20 '22 09:09 micdenny

I'ts working here. ;) Do you have a bug or issue number?

Yes it is issue #3187

NightFox7 avatar Sep 20 '22 09:09 NightFox7

Hm. The accompanying issue (#3020) that this PR is supposed to be resolved was closed by merging #3190. Both #3020 and #3190 are also targeting v6 (main), while this PR is targeting v5. It may be best to retarget this against main, due to the amount of changes done to branch inheritance in #3190 and the fact that the changes may be considered breaking.

asbjornu avatar Oct 25 '22 09:10 asbjornu

@micdenny please rebase your PR on top of current state of main

arturcic avatar Mar 19 '23 10:03 arturcic

Closing as it's too old based on the code base. Please consider opening a new issue/PR based on the current code base

arturcic avatar Mar 13 '24 15:03 arturcic