Skip to content

Commit e242079

Browse files
author
roeil
committed
feat(paths-filter): first commit that supports paths filtering (ignore inclusive only)
1 parent 754e71c commit e242079

File tree

20 files changed

+145
-8
lines changed

20 files changed

+145
-8
lines changed

docs/input/docs/workflows/GitFlow/v1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ branches:
148148
is-main-branch: false
149149
ignore:
150150
sha: []
151+
paths: []
151152
mode: ContinuousDelivery
152153
label: '{BranchName}'
153154
increment: Inherit

docs/input/docs/workflows/GitHubFlow/v1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ branches:
9797
is-main-branch: false
9898
ignore:
9999
sha: []
100+
paths: []
100101
mode: ContinuousDelivery
101102
label: '{BranchName}'
102103
increment: Inherit

docs/input/docs/workflows/TrunkBased/preview1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ branches:
8282
pre-release-weight: 30000
8383
ignore:
8484
sha: []
85+
paths: []
8586
mode: ContinuousDelivery
8687
label: '{BranchName}'
8788
increment: Inherit

schemas/6.1/GitVersion.configuration.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@
189189
"null"
190190
]
191191
},
192+
"paths": {
193+
"description": "A sequence of file paths to be excluded from the version calculations.",
194+
"type": "array",
195+
"items": {
196+
"type": "string"
197+
}
198+
},
192199
"sha": {
193200
"description": "A sequence of SHAs to be excluded from the version calculations.",
194201
"$ref": "#/$defs/hashSetOfString"

src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ branches:
148148
is-main-branch: false
149149
ignore:
150150
sha: []
151+
paths: []
151152
mode: ContinuousDelivery
152153
label: '{BranchName}'
153154
increment: Inherit

src/GitVersion.Configuration.Tests/Workflows/approved/GitFlow/v1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ branches:
148148
is-main-branch: false
149149
ignore:
150150
sha: []
151+
paths: []
151152
mode: ContinuousDelivery
152153
label: '{BranchName}'
153154
increment: Inherit

src/GitVersion.Configuration.Tests/Workflows/approved/GitHubFlow/v1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ branches:
9797
is-main-branch: false
9898
ignore:
9999
sha: []
100+
paths: []
100101
mode: ContinuousDelivery
101102
label: '{BranchName}'
102103
increment: Inherit

src/GitVersion.Configuration.Tests/Workflows/approved/TrunkBased/preview1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ branches:
8282
pre-release-weight: 30000
8383
ignore:
8484
sha: []
85+
paths: []
8586
mode: ContinuousDelivery
8687
label: '{BranchName}'
8788
increment: Inherit

src/GitVersion.Configuration/IgnoreConfiguration.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.ObjectModel;
12
using GitVersion.Configuration.Attributes;
23

34
namespace GitVersion.Configuration;
@@ -22,4 +23,11 @@ public string? BeforeString
2223
[JsonPropertyName("sha")]
2324
[JsonPropertyDescription("A sequence of SHAs to be excluded from the version calculations.")]
2425
public HashSet<string> Shas { get; init; } = [];
26+
27+
[JsonIgnore]
28+
IReadOnlyCollection<string> IIgnoreConfiguration.Paths => Paths;
29+
30+
[JsonPropertyName("paths")]
31+
[JsonPropertyDescription("A sequence of file paths to be excluded from the version calculations.")]
32+
public Collection<string> Paths { get; init; } = [];
2533
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using GitVersion.Core.Tests.Helpers;
2+
using GitVersion.Git;
3+
using GitVersion.VersionCalculation;
4+
5+
namespace GitVersion.Core.Tests;
6+
7+
[TestFixture]
8+
public class PathFilterTests : TestBase
9+
{
10+
[Test]
11+
public void VerifyNullGuard() => Should.Throw<ArgumentNullException>(() => new PathFilter(null!, null!, null!));
12+
13+
[Test]
14+
public void VerifyNullGuard2()
15+
{
16+
var sut = new PathFilter(null!, null!, [""]);
17+
18+
Should.Throw<ArgumentNullException>(() => sut.Exclude((ICommit?)null, out _));
19+
}
20+
}

0 commit comments

Comments
 (0)