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

Abierto
#4,433 11 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@fzlzjerry ya está trabajando en esto.

Desde el 17/8/2026.

  • #5140 de @fzlzjerry — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
58/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, git
Área
devtools, release

Línea de trabajo

Comienza con MergeMessageVersionStrategy.cs y las pruebas de RepositoryFixture; después, compara los escenarios de GitFlowConfigurationBuilder y TrunkBasedConfigurationBuilder. Comprueba cómo se representa la configuración de las estrategias y cómo se habilitan actualmente los incrementos de ramas fusionadas. La tarea estará terminada cuando los escenarios de aceptación de GitFlow y GitHubFlow produzcan el incremento patch o minor esperado, con pruebas que cubran cada caso.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
C#
Estrellas
3.1k
Forks
661
Merge medio
7 h 4 min
PR fusionados (30 d)
77

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de GitTools/GitVersion

Todos los issues de GitTools/GitVersion

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.