Fix #650 - remove the BuildGraphOf property (#1302)

This commit is contained in:
Nate McMaster 2018-08-10 09:42:43 -07:00 committed by GitHub
parent efdb625c03
commit 555f10b5f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 30 deletions

View File

@ -239,7 +239,6 @@
Artifacts="@(ArtifactInfo);@(ShippedArtifactInfo)"
Repositories="@(Repository);@(ShippedRepository)"
Dependencies="@(ExternalDependency)"
StartGraphAt="$(BuildGraphOf)"
Properties="Configuration=$(Configuration);BuildNumber=$(BuildNumber);DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)">
<Output TaskParameter="RepositoryBuildOrder" ItemName="RepositoryBuildOrder" />
</RepoTasks.AnalyzeBuildGraph>

View File

@ -38,8 +38,6 @@ namespace RepoTasks
[Required]
public string Properties { get; set; }
public string StartGraphAt { get; set; }
/// <summary>
/// The order in which to build repositories
/// </summary>
@ -270,14 +268,13 @@ namespace RepoTasks
return repo;
}).ToList();
var graph = GraphBuilder.Generate(repositories, StartGraphAt, Log);
var graph = GraphBuilder.Generate(repositories, Log);
var repositoriesWithOrder = new List<(ITaskItem repository, int order)>();
foreach (var repository in repositories)
{
var graphNodeRepository = graph.FirstOrDefault(g => g.Repository.Name == repository.Name);
if (graphNodeRepository == null)
{
// StartGraphAt was specified so the graph is incomplete.
continue;
}

View File

@ -11,7 +11,7 @@ namespace RepoTools.BuildGraph
{
public static class GraphBuilder
{
public static IList<GraphNode> Generate(IList<Repository> repositories, string root, TaskLoggingHelper log)
public static IList<GraphNode> Generate(IList<Repository> repositories, TaskLoggingHelper log)
{
// Build global list of primary projects
var primaryProjects = repositories.SelectMany(c => c.Projects)
@ -19,15 +19,9 @@ namespace RepoTools.BuildGraph
var graphNodes = repositories.Select(r => new GraphNode { Repository = r })
.ToDictionary(r => r.Repository);
GraphNode searchRoot = null;
foreach (var project in repositories.SelectMany(r => r.AllProjects))
{
var thisProjectRepositoryNode = graphNodes[project.Repository];
if (!string.IsNullOrEmpty(root) && string.Equals(root, project.Repository.Name, StringComparison.OrdinalIgnoreCase))
{
searchRoot = thisProjectRepositoryNode;
}
foreach (var packageDependency in project.PackageReferences)
{
@ -50,25 +44,7 @@ namespace RepoTools.BuildGraph
}
}
var results = new HashSet<GraphNode>();
if (searchRoot != null)
{
Visit(results, searchRoot);
return results.ToList();
}
return graphNodes.Values.ToList();
}
private static void Visit(HashSet<GraphNode> results, GraphNode searchRoot)
{
if (results.Add(searchRoot))
{
foreach (var node in searchRoot.Outgoing)
{
Visit(results, node);
}
}
}
}
}