Skip to content

Commit ccb8e63

Browse files
committed
fix sequence contains no elements when using IgnoreConfig
1 parent 4c945f4 commit ccb8e63

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using GitTools.Testing;
2+
using GitVersion.Configuration;
3+
using GitVersion.Extensions;
4+
using GitVersion.Model.Configuration;
5+
using GitVersionCore.Tests.Helpers;
6+
using NUnit.Framework;
7+
8+
namespace GitVersionCore.Tests.IntegrationTests
9+
{
10+
[TestFixture]
11+
public class IgnoreBeforeScenarios : TestBase
12+
{
13+
[Test]
14+
public void ShouldFallbackToBaseVersionWhenAllCommitsAreIgnored()
15+
{
16+
using var fixture = new EmptyRepositoryFixture();
17+
var commit = fixture.Repository.MakeACommit();
18+
19+
var config = new ConfigurationBuilder()
20+
.Add(new Config
21+
{
22+
Ignore = new IgnoreConfig
23+
{
24+
Before = commit.When().AddMinutes(1)
25+
}
26+
}).Build();
27+
28+
fixture.AssertFullSemver("0.1.0+0", config);
29+
}
30+
}
31+
}

src/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,27 @@ public BaseVersion GetBaseVersion()
2828
using (log.IndentLog("Calculating base versions"))
2929
{
3030
var baseVersions = strategies
31-
.SelectMany(s => s.GetVersions())
32-
.Where(v =>
31+
.SelectMany(s =>
3332
{
34-
if (v == null) return false;
35-
36-
log.Info(v.ToString());
37-
38-
foreach (var filter in context.Configuration.VersionFilters)
39-
{
40-
if (filter.Exclude(v, out var reason))
33+
return s.GetVersions()
34+
.Where(v =>
4135
{
42-
log.Info(reason);
43-
return false;
44-
}
45-
}
46-
47-
return true;
36+
if (v == null) return false;
37+
if (s is FallbackVersionStrategy) return true;
38+
39+
log.Info(v.ToString());
40+
41+
foreach (var filter in context.Configuration.VersionFilters)
42+
{
43+
if (filter.Exclude(v, out var reason))
44+
{
45+
log.Info(reason);
46+
return false;
47+
}
48+
}
49+
50+
return true;
51+
});
4852
})
4953
.Select(v => new Versions
5054
{

0 commit comments

Comments
 (0)