Skip to content
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

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

Closed
wants to merge 8 commits into from

Conversation

micdenny
Copy link

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:

  • 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.

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.

Please run dotnet format on your code and have a look at my other remarks. Otherwise, I think this looks good on the condition that all tests succeed. 🤞🏼

@micdenny
Copy link
Author

micdenny commented Sep 13, 2022

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
Copy link
Author

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

@NightFox7
Copy link

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");
}

@micdenny
Copy link
Author

micdenny commented Sep 13, 2022

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
Copy link
Author

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

image

@micdenny
Copy link
Author

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

@HHobeck
Copy link
Contributor

HHobeck commented Sep 18, 2022

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?

@NightFox7
Copy link

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

@micdenny
Copy link
Author

micdenny commented Sep 20, 2022

@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'

@NightFox7
Copy link

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

Yes it is issue #3187

@asbjornu
Copy link
Member

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.

@arturcic
Copy link
Member

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

@arturcic arturcic added the stale label Apr 8, 2023
@HHobeck HHobeck removed the stale label May 17, 2023
@arturcic
Copy link
Member

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 arturcic closed this Mar 13, 2024
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.

5 participants