Skip to content

feat: resolve increments from merged branches - #5140

Open
fzlzjerry wants to merge 23 commits into
GitTools:mainfrom
fzlzjerry:feat/4433-prevent-merged-branch-increment
Open

feat: resolve increments from merged branches#5140
fzlzjerry wants to merge 23 commits into
GitTools:mainfrom
fzlzjerry:feat/4433-prevent-merged-branch-increment

Conversation

@fzlzjerry

@fzlzjerry fzlzjerry commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Description

Moves merged-branch increment selection into IncrementStrategyFinder.DetermineIncrementedField, so every version strategy that already uses the finder receives the same behavior without adding a separate strategy or configuration surface.

For a branch with merge-message tracking enabled that is either an effective main branch or a compatible descendant preserving main-branch history through linear work and main-to-descendant updates, the finder separates first-parent target work from recognized two-parent merges. It calculates each source branch's effective increment from the merged history, preserves source +semver / =semver handling, and applies the target/source settings as follows:

Target of-merged-branch Source when-branch-merged Effective contribution
false false Target + source increment
false true Target increment
true false Source increment
true true Target increment

Main-to-descendant update merges carry main's recursively derived version floor rather than treating main as a completed source branch. Unrelated intervening merges still keep the descendant outside merge-history processing.

Direct target commits still contribute the target increment, unrecognized merge histories remain target-configured work, synthetic pull-request refs stay outside merge-history processing, and the highest contribution across multiple merges wins. Inherited source increments are resolved from the historical merged tip, including deleted or recreated topic refs and source branches that absorb the topic later. Per-merge and ancestry results use configuration-aware cache keys because the finder evaluates multiple base-version candidates for the same current commit.

Related Issue

Resolves #4433

Motivation and Context

Outside mainline calculation, a no-fast-forward merge currently falls back to the target branch's configured increment. This makes a patch hotfix merged into a minor-increment main branch produce a minor version, and a minor feature merged into a patch-increment main branch produce a patch version. The increment finder already owns configured and commit-message increment precedence, so handling merged histories there keeps the behavior consistent across dependent version strategies.

How Has This Been Tested?

Revalidated on Linux with .NET SDK 10.0.400 at 6d1169c5f after rebasing onto 88086843:

  • Added 46 integration cases covering the four effective configuration combinations, GitFlow/GitHubFlow acceptance scenarios, multiple merges and reset directives, target work before and after a merge, source commit-message overrides, unrecognized and ignored-merge side histories including chronological directive ordering across recognized boundaries, tagged and future-dated source tips including selected stable tags across source labels, inherited prevention and effective main-branch settings including source-branch inheritance, ignored branches including current and compatible-descendant main-history exceptions, synthetic pull-request refs, intervening target tags, pruned target segments, and off-first-parent base boundaries, nested and sibling inheritance for historical and retained tips, descendant-branch version floors including main update merges and an unrelated-merge guard, historical/local/remote source resolution, and retained/deleted orphan fallback parity including unresolved-Inherit skipping.
  • Added a focused IncrementStrategyFinder unit case proving that commit-message cache entries are isolated by regex configuration.
  • Updated the existing GitFlow/GitHubFlow alignment and merge scenarios to assert the corrected results.
  • dotnet build ./src/GitVersion.slnx --no-restore --verbosity:minimal -m:1 — succeeded with 0 warnings and 0 errors.
  • dotnet test --solution ./src/GitVersion.slnx --no-build --no-restore --max-parallel-test-modules 1 --no-progress --output Normal with TMPDIR and RUNNER_TEMP set to a clean directory under /var/tmp with no .git ancestor — 37,498 succeeded, 0 failed.
  • dotnet format --verify-no-changes ./src/GitVersion.slnx --no-restore — succeeded.
  • git diff --check — succeeded.

Screenshots (if appropriate):

N/A

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.

Copilot AI lite review requested due to automatic review settings August 17, 2026 11:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18f6910930

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings August 17, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e34bfa475

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fzlzjerry
fzlzjerry force-pushed the feat/4433-prevent-merged-branch-increment branch from 4e34bfa to f6b83bb Compare August 17, 2026 12:57
Copilot AI review requested due to automatic review settings August 17, 2026 12:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6b83bb5c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings August 17, 2026 13:44
@fzlzjerry
fzlzjerry force-pushed the feat/4433-prevent-merged-branch-increment branch from f6b83bb to 52598be Compare August 17, 2026 13:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52598be177

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings August 17, 2026 14:02
@fzlzjerry
fzlzjerry force-pushed the feat/4433-prevent-merged-branch-increment branch from 52598be to 1c8f29f Compare August 17, 2026 14:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@arturcic
arturcic requested a review from HHobeck August 17, 2026 16:41
Copilot AI review requested due to automatic review settings August 18, 2026 12:24
@fzlzjerry
fzlzjerry force-pushed the feat/4433-prevent-merged-branch-increment branch from 1c8f29f to 3f8211c Compare August 18, 2026 12:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f8211c580

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings August 18, 2026 12:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8823790f7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings August 18, 2026 13:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cee297f10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/input/docs/reference/version-sources.md Outdated
Copilot AI review requested due to automatic review settings August 18, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@arturcic

arturcic commented Sep 8, 2026

Copy link
Copy Markdown
Member

@fzlzjerry please rebase your changes on the latest main.

Copilot AI review requested due to automatic review settings September 8, 2026 11:46
@fzlzjerry
fzlzjerry force-pushed the feat/4433-prevent-merged-branch-increment branch from 5b197cf to 6d1169c Compare September 8, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@fzlzjerry

Copy link
Copy Markdown
Contributor Author

@arturcic Rebased onto current main (88086843) as 6d1169c5f. All 23 commits replayed without content changes; the range-diff and aggregate patch identity match the previous branch.

With .NET SDK 10.0.400, the src/GitVersion.slnx build has 0 warnings/errors, all 37,498 committed solution tests pass, and formatting verification passes. This is a rebase only; the behavior questions from the earlier discussion remain separate.

@arturcic

arturcic commented Sep 8, 2026

Copy link
Copy Markdown
Member

@HHobeck can you have a new review?

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

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.

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

5 participants