Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-a committed Apr 11, 2021
2 parents 6822b1f + 1284dac commit 3ba696a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 22 deletions.
17 changes: 16 additions & 1 deletion src/Tasks.Tests/CalculateProjectTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void Should_Return_Other_If_Cake_Is_Not_Referenced()
{
// given
var fixture = new CalculateProjectTypeFixture();
fixture.WithProjectNames("Cake.7zip","Cake.Buildsystems.Module","Cake.Recipe","foo");
fixture.WithProjectNames("Cake.7zip","Cake.Buildsystems.Module","foo");
fixture.WithoutCakeReference();

// when
Expand All @@ -97,5 +97,20 @@ public void Should_Return_Other_If_Cake_Is_Not_Referenced()
// then
fixture.Output.Should().BeEquivalentTo(ExpectedTypeOther);
}

[Fact]
public void Should_Return_Recipe_For_Recipes_Even_If_Cake_Is_Not_Referenced()
{
// given
var fixture = new CalculateProjectTypeFixture();
fixture.WithProjectNames("Cake.Recipe");
fixture.WithoutCakeReference();

// when
fixture.Execute();

// then
fixture.Output.Should().BeEquivalentTo(ExpectedTypeRecipe);
}
}
}
52 changes: 31 additions & 21 deletions src/Tasks/CalculateProjectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,6 @@ public override bool Execute()
return true;
}

var requiredCakeReferences = CakeRequiredReference
.Select(x => x.ToString())
.Where(x => !string.IsNullOrEmpty(x))
.Select(x => x.ToLowerInvariant())
.ToList();

var references = References
.Select(x => x.ToString())
.Where(x => !string.IsNullOrEmpty(x))
.Select(x => x.ToLowerInvariant())
.ToList();

if (!references.Any(x => requiredCakeReferences.Contains(x)))
{
Output = CakeProjectType.Other.ToString();
Log.LogMessage(
LogLevel,
$"No reference to Cake found. Setting output to '{Output}'.");
return true;
}

var names = ProjectNames
.Select(x => x.ToString())
.Where(x => !string.IsNullOrEmpty(x))
Expand Down Expand Up @@ -139,6 +118,37 @@ public override bool Execute()
Log.LogMessage(
LogLevel,
$"The name '{match}' suggest a {Output} project. Setting output to '{Output}'.");
break;
}

// Recipes are special, as they probably never have a reference to Cake..
if (Output == CakeProjectType.Recipe.ToString())
{
return true;
}

var requiredCakeReferences = CakeRequiredReference
.Select(x => x.ToString())
.Where(x => !string.IsNullOrEmpty(x))
.Select(x => x.ToLowerInvariant())
.ToList();

var references = References
.Select(x => x.ToString())
.Where(x => !string.IsNullOrEmpty(x))
.Select(x => x.ToLowerInvariant())
.ToList();

if (!references.Any(x => requiredCakeReferences.Contains(x)))
{
Output = CakeProjectType.Other.ToString();
Log.LogMessage(
LogLevel,
$"No reference to Cake found. Setting output to '{Output}'.");
}

if (!string.IsNullOrEmpty(Output))
{
return true;
}

Expand Down

0 comments on commit 3ba696a

Please sign in to comment.