[FEATURE]: Support of prevent increment of merged branch in GitHub workflow

Aperta
#4,433 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@fzlzjerry ci sta già lavorando.

Dal 17/8/2026.

  • #5140 di @fzlzjerry — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, git
Ambito
devtools, release

Direzione di ricerca

Inizia da MergeMessageVersionStrategy.cs e dai test di RepositoryFixture, quindi confronta gli scenari di GitFlowConfigurationBuilder e TrunkBasedConfigurationBuilder. Verifica come viene rappresentata la configurazione delle strategie e come vengono attualmente abilitati gli incrementi dei branch uniti. Il lavoro è completato quando gli scenari di accettazione di GitFlow e GitHubFlow producono l’incremento patch o minor previsto, con test che coprono ogni caso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature help wanted
Prerequisites
  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported
GitVersion package

GitVersion.Tool

GitVersion version

6.1.0

Operating system

N/A, Windows

What are you seeing?

The feature to increment the version when merging into a branch by using the increment of the source branch is currently supported only in the TrunkBased workflow. It would be good to have the same behavior in the GitFlow and GitHubFlow workflows as well.

Hint: Needs to be implemented probably in MergeMessageVersionStrategy. We should create a separate version strategy class to be able to enable or disable the behavior via the configuration (strategies property).

What is expected?

Scenario 1:
When merging a hotfix branch with increment patch to a main branch with increment minor, I would expect the increment to be patch and not minor in a GitFlow workflow.

Scenario 2:
When merging a feature branch with increment minor to a main branch with increment patch, I would expect the increment to be minor and not patch in a GitFlow workflow.

Steps to Reproduce

Scenario 1:

 *  54 minutes ago  (HEAD -> main)
 |\
 | A 56 minutes ago  (hotfix/foo)
 |/
 *  58 minutes ago (tag: 1.0.0)

Scenario 2:

 *  54 minutes ago  (HEAD -> main)
 |\
 | A 56 minutes ago  (feature/foo)
 |/
 *  58 minutes ago (tag: 1.0.0)

See RepostioryFixture Test section below for more information.

RepositoryFixture Test
[Test]
public void Given_main_with_increment_minor_and_hotfix_with_increment_patch_When_hotfix_merged_into_main_Then_increment_should_be_patch()
{
    using var fixture = new EmptyRepositoryFixture("main");

    var configurationBuilder = TrunkBasedConfigurationBuilder.New
        .WithBranch("main", builder => builder
            .WithIncrement(IncrementStrategy.Minor)
            .WithDeploymentMode(DeploymentMode.ContinuousDelivery)
            .WithPreventIncrementOfMergedBranch(true)
        ).WithBranch("hotfix", builder => builder.WithIncrement(IncrementStrategy.Patch));

    fixture.MakeATaggedCommit("1.0.0");
    fixture.BranchTo("hotfix/foo");
    fixture.MakeACommit();
    fixture.MergeTo("main");

    // ✅ succeeds as expected
    fixture.AssertFullSemver("1.0.1-2", configurationBuilder.Build());
}

It would be good to have the same behavior in the GitFlow and GitHubFlow workflows:

[Test]
public void Given_main_with_increment_minor_and_hotfix_with_increment_patch_When_hotfix_merged_into_main_Then_increment_should_be_patch()
{
    using var fixture = new EmptyRepositoryFixture("main");

    var configurationBuilder = GitFlowConfigurationBuilder.New
        .WithBranch("main", builder => builder.WithIncrement(IncrementStrategy.Minor).WithPreventIncrementOfMergedBranch(true))
        .WithBranch("hotfix", builder => builder.WithIncrement(IncrementStrategy.Patch));

    fixture.MakeATaggedCommit("1.0.0");
    fixture.BranchTo("hotfix/foo");
    fixture.MakeACommit();
    fixture.MergeTo("main");

    // ❔ expected: "1.0.1-2"
    fixture.AssertFullSemver("1.1.0-2", configurationBuilder.Build());
}

Additional acceptance criteria:

[Test]
public void Given_main_with_increment_patch_and_feature_with_increment_minor_When_feature_merged_into_main_Then_increment_should_be_minor()
{
    using var fixture = new EmptyRepositoryFixture("main");

    var configurationBuilder = GitFlowConfigurationBuilder.New
        .WithBranch("main", builder => builder
            .WithIncrement(IncrementStrategy.Patch)
            .WithPreventIncrementOfMergedBranch(true)
        ).WithBranch("feature", builder => builder.WithIncrement(IncrementStrategy.Minor));

    fixture.MakeATaggedCommit("1.0.0");
    fixture.BranchTo("feature/foo");
    fixture.MakeACommit();
    fixture.MergeTo("main");

    // ❔ expected: "1.1.0-2"
    fixture.AssertFullSemver("1.0.1-2", configurationBuilder.Build());
}
Output log or link to your CI build (if appropriate).
N/A
Lingua principale
C#
Stelle
3.1k
Fork
661
Merge medio
7h 4m
PR unite (30g)
77

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GitTools/GitVersion

Tutte le issue di GitTools/GitVersion

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.