Skip to content

feat: support regex branch exclusions - #5148

Merged
arturcic merged 2 commits into
mainfrom
feature/5130-ignore-branches
Aug 19, 2026
Merged

feat: support regex branch exclusions#5148
arturcic merged 2 commits into
mainfrom
feature/5130-ignore-branches

Conversation

@arturcic

@arturcic arturcic commented Aug 17, 2026

Copy link
Copy Markdown
Member

Description

Adds ignore.branches, a sequence of regular expressions for excluding auxiliary branches from version-source discovery and build-server normalization.

  • Matches case-insensitively against branch names without the local or remote prefix.
  • Uses OR semantics and treats local and remote-tracking names equivalently.
  • Preserves the current branch and explicitly selected target branch.
  • Keeps shared commits, shared tags, and configuration inheritance eligible.
  • Avoids creating or updating ignored local branches during normalization while leaving existing local refs untouched.
  • Includes configuration, public API, generated schema/workflows, documentation, calculation scenarios, and normalization coverage.

Related issue

Closes #5130.

Stack

  1. #5151 - order configuration properties alphabetically
  2. #5147 - ignore tags
  3. This PR - ignore branches

Depends-On: #5147

Validation

  • GitVersion.Configuration.Tests: 113 passed.
  • Focused GitVersion.Core.Tests with LibGit2Sharp: 29 passed.
  • Focused GitVersion.Core.Tests with managed Git: 29 passed.
  • BuildPrepare completed successfully with zero warnings and errors.
  • dotnet format src/GitVersion.slnx --no-restore completed successfully.
  • Regenerated only schemas/7.0/GitVersion.configuration.json.

Checklist

  • Code follows the project style.
  • Documentation is updated.
  • Tests cover the change.
  • New and existing affected tests pass.

@mergify

mergify Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 ⛓️ Depends-On Requirements

Requirement based on the presence of Depends-On in the body of the pull request

@arturcic arturcic mentioned this pull request Aug 17, 2026
4 tasks
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from 56b5abc to dce80c2 Compare August 17, 2026 20:45
@arturcic
arturcic marked this pull request as ready for review August 17, 2026 21:35
Copilot AI lite review requested due to automatic review settings August 17, 2026 21:35

This comment was marked as low quality.

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.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.

@arturcic

Copy link
Copy Markdown
Member Author

Hi @HHobeck, could you please take a look at this PR when you have a chance? Thank you!

@arturcic
arturcic requested a review from HHobeck August 17, 2026 21:57
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from dce80c2 to b244656 Compare August 18, 2026 06:29
Copilot AI review requested due to automatic review settings August 18, 2026 06:29

This comment was marked as low quality.

@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from b244656 to 72a59a4 Compare August 18, 2026 08:42
Copilot AI review requested due to automatic review settings August 18, 2026 08:42

This comment was marked as duplicate.

Copilot AI review requested due to automatic review settings August 18, 2026 08:51
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from 72a59a4 to 459f96e Compare August 18, 2026 08:51

This comment was marked as duplicate.

@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from 459f96e to cf3200a Compare August 18, 2026 10:22
Copilot AI review requested due to automatic review settings August 18, 2026 10:22

This comment was marked as duplicate.

Copilot AI review requested due to automatic review settings August 18, 2026 10:37
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from cf3200a to 0116330 Compare August 18, 2026 10:37
Comment thread src/GitVersion.Core/Extensions/ConfigurationExtensions.cs Fixed
Base automatically changed from feature/5130-ignore-tags to main August 19, 2026 11:08
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from 3c8c8ec to f2ede0c Compare August 19, 2026 11:08
Copilot AI review requested due to automatic review settings August 19, 2026 11:15
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from f2ede0c to f89fa54 Compare August 19, 2026 11:15

This comment was marked as duplicate.

Copilot AI review requested due to automatic review settings August 19, 2026 12:49
@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from f89fa54 to 8298043 Compare August 19, 2026 12:49

This comment was marked as duplicate.

@arturcic
arturcic force-pushed the feature/5130-ignore-branches branch from 8298043 to a8e8c2e Compare August 19, 2026 12:57
@sonarqubecloud

Copy link
Copy Markdown

@arturcic

Copy link
Copy Markdown
Member Author

@HHobeck when you have time please have a new look

@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@HHobeck HHobeck 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.

Could you change the configuration for GitFlow, GitHubFlow and TrunkbasedWorkflow and ignore all branches who are not permitted?

arturcic

This comment was marked as duplicate.

@arturcic

Copy link
Copy Markdown
Member Author

Could you change the configuration for GitFlow, GitHubFlow and TrunkbasedWorkflow and ignore all branches who are not permitted?

@HHobeck, could you clarify which branches should be considered "not permitted"? Each workflow currently has an unknown catch-all, while adding all configured branch patterns to ignore.branches would exclude the workflow’s normal version sources.

@HHobeck

HHobeck commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Could you change the configuration for GitFlow, GitHubFlow and TrunkbasedWorkflow and ignore all branches who are not permitted?

@HHobeck, could you clarify which branches should be considered "not permitted"? Each workflow currently has an unknown catch-all, while adding all configured branch patterns to ignore.branches would exclude the workflow’s normal version sources.

Good point. These two concepts seem to be clashing. But is it more like if your current branch is not known, it will still be used to calculate the version? Or what happens if your current branch is ignored?

@arturcic

Copy link
Copy Markdown
Member Author

Good point. These two concepts seem to be clashing. But is it more like if your current branch is not known, it will still be used to calculate the version? Or what happens if your current branch is ignored?

Codex researched the current behavior and helped draft this clarification:

An unmatched current branch uses the workflow’s unknown configuration and is calculated normally. If the current branch matches ignore.branches, it is still protected during normalization and calculated normally. The option only prevents matching branches from being considered as version sources when calculating another branch; it does not disable calculation for the checked-out branch.

@HHobeck

HHobeck commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Codex researched the current behavior and helped draft this clarification:

An unmatched current branch uses the workflow’s unknown configuration and is calculated normally. If the current branch matches ignore.branches, it is still protected during normalization and calculated normally. The option only prevents matching branches from being considered as version sources when calculating another branch; it does not disable calculation for the checked-out branch.

So it would make sense to ignore the not known branch, correct? It was just an idea to improve performance. If you think it is not necessary please go ahead and leave it like it is.

@arturcic

Copy link
Copy Markdown
Member Author

Let's keep it like that, please approve

@arturcic

Copy link
Copy Markdown
Member Author

@Mergifyio refresh

@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

refresh

✅ Pull request refreshed

@arturcic
arturcic merged commit 4fd8d74 into main Aug 19, 2026
67 checks passed
@arturcic
arturcic deleted the feature/5130-ignore-branches branch August 19, 2026 14:24
@mergify

mergify Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Thank you @arturcic for your contribution!

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 regex-based branch and tag exclusions in ignore configuration

5 participants