private static List <ProjectChangeInfo> GetChangesPerProject(ConfigFile config, IEnumerable <ProjectInfo> allProjects, IEnumerable <GitCommitInfo> gitHistory) { Dictionary <ProjectInfo, ProjectChangeInfo> changesPerProject = new Dictionary <ProjectInfo, ProjectChangeInfo>(); foreach (GitCommitInfo commit in gitHistory) { // Iterate over all projects that are affected by this commit foreach (ProjectInfo project in allProjects) { bool isAffectedByCommit = false; List <string> localModifiedFiles = new List <string>(); foreach (string filePath in commit.FilePaths) { if (IsPathLocatedIn(filePath, project.ProjectRootDir)) { isAffectedByCommit = true; localModifiedFiles.Add(filePath); } } if (!isAffectedByCommit) { continue; } // Retrieve the change log information about this project ProjectChangeInfo changeInfo; if (!changesPerProject.TryGetValue(project, out changeInfo)) { changeInfo = new ProjectChangeInfo { Project = project, }; changesPerProject.Add(project, changeInfo); } // Add modified files foreach (string filePath in localModifiedFiles) { changeInfo.ModifiedFilePaths.Add(filePath); } // Add changelog entries, if we have meaningful comments if (!string.IsNullOrEmpty(commit.Title) && !string.IsNullOrEmpty(commit.Message)) { string[] msgItems = commit.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); changeInfo.Titles.Add(commit.Title); changeInfo.ChangeLog.AddRange(msgItems); } } } return(changesPerProject.Values.ToList()); }
private static List <ProjectChangeInfo> GetChangesPerProject(ConfigFile config, IEnumerable <ProjectInfo> allProjects, IEnumerable <GitCommitInfo> gitHistory) { Dictionary <ProjectInfo, ProjectChangeInfo> changesPerProject = new Dictionary <ProjectInfo, ProjectChangeInfo>(); foreach (GitCommitInfo commit in gitHistory) { // Iterate over all projects that are affected by this commit foreach (ProjectInfo project in allProjects) { bool isAffectedByCommit = false; // Determine projects that are located inside this project's root directory ProjectInfo[] subProjects = allProjects .Where(p => p != project && IsPathLocatedIn(p.ProjectRootDir, project.ProjectRootDir)) .ToArray(); // Are files of this project modified? List <string> localModifiedFiles = new List <string>(); foreach (string filePath in commit.FilePaths) { // Not located in this project? Skip. if (!IsPathLocatedIn(filePath, project.ProjectRootDir)) { continue; } // Located in a sub-project? Skip. if (subProjects.Any(p => IsPathLocatedIn(filePath, p.ProjectRootDir))) { continue; } isAffectedByCommit = true; localModifiedFiles.Add(filePath); } // Skip all projects that are not affected by the commit at all if (!isAffectedByCommit) { continue; } // Retrieve the change log information about this project ProjectChangeInfo changeInfo; if (!changesPerProject.TryGetValue(project, out changeInfo)) { changeInfo = new ProjectChangeInfo { Project = project, }; changesPerProject.Add(project, changeInfo); } // Add modified files foreach (string filePath in localModifiedFiles) { changeInfo.ModifiedFilePaths.Add(filePath); } // Add changelog entries, if we have meaningful comments if (!string.IsNullOrEmpty(commit.Title) && !string.IsNullOrEmpty(commit.Message)) { string[] msgItems = commit.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); changeInfo.Titles.Add(commit.Title); changeInfo.ChangeLog.AddRange(msgItems); } } } // For every non-default project, check if there was a non-default-project dependency // modified and add a version bump change. This will make sure sample projects // will always depend on the latest released version of their core and editor projects. foreach (ProjectInfo dependency in changesPerProject.Keys.ToArray()) { if (dependency.IsDefaultPackage) { continue; } foreach (ProjectInfo dependent in allProjects) { if (dependent.IsDefaultPackage) { continue; } if (!dependent.NuSpecDependencies.Contains(dependency.NuSpecPackageId)) { continue; } if (changesPerProject.ContainsKey(dependent)) { continue; } // Create a new change info for the dependent project ProjectChangeInfo changeInfo; changeInfo = new ProjectChangeInfo { Project = dependent }; changesPerProject.Add(dependent, changeInfo); // Add a dummy change log about this project changeInfo.Titles.Add("Updated Dependencies"); changeInfo.ChangeLog.Add(string.Format("#CHANGE: Updated {0} dependency", dependency.NuSpecPackageId)); } } return(changesPerProject.Values.ToList()); }
private static List<ProjectChangeInfo> GetChangesPerProject(ConfigFile config, IEnumerable<ProjectInfo> allProjects, IEnumerable<GitCommitInfo> gitHistory) { Dictionary<ProjectInfo, ProjectChangeInfo> changesPerProject = new Dictionary<ProjectInfo,ProjectChangeInfo>(); foreach (GitCommitInfo commit in gitHistory) { // Iterate over all projects that are affected by this commit foreach (ProjectInfo project in allProjects) { bool isAffectedByCommit = false; List<string> localModifiedFiles = new List<string>(); foreach (string filePath in commit.FilePaths) { if (IsPathLocatedIn(filePath, project.ProjectRootDir)) { isAffectedByCommit = true; localModifiedFiles.Add(filePath); } } if (!isAffectedByCommit) continue; // Retrieve the change log information about this project ProjectChangeInfo changeInfo; if (!changesPerProject.TryGetValue(project, out changeInfo)) { changeInfo = new ProjectChangeInfo { Project = project, }; changesPerProject.Add(project, changeInfo); } // Add modified files foreach (string filePath in localModifiedFiles) { changeInfo.ModifiedFilePaths.Add(filePath); } // Add changelog entries, if we have meaningful comments if (!string.IsNullOrEmpty(commit.Title) && !string.IsNullOrEmpty(commit.Message)) { string[] msgItems = commit.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); changeInfo.Titles.Add(commit.Title); changeInfo.ChangeLog.AddRange(msgItems); } } } return changesPerProject.Values.ToList(); }
private static List<ProjectChangeInfo> GetChangesPerProject(ConfigFile config, IEnumerable<ProjectInfo> allProjects, IEnumerable<GitCommitInfo> gitHistory) { Dictionary<ProjectInfo, ProjectChangeInfo> changesPerProject = new Dictionary<ProjectInfo,ProjectChangeInfo>(); foreach (GitCommitInfo commit in gitHistory) { // Iterate over all projects that are affected by this commit foreach (ProjectInfo project in allProjects) { bool isAffectedByCommit = false; // Determine projects that are located inside this project's root directory ProjectInfo[] subProjects = allProjects .Where(p => p != project && IsPathLocatedIn(p.ProjectRootDir, project.ProjectRootDir)) .ToArray(); // Are files of this project modified? List<string> localModifiedFiles = new List<string>(); foreach (string filePath in commit.FilePaths) { // Not located in this project? Skip. if (!IsPathLocatedIn(filePath, project.ProjectRootDir)) continue; // Located in a sub-project? Skip. if (subProjects.Any(p => IsPathLocatedIn(filePath, p.ProjectRootDir))) continue; isAffectedByCommit = true; localModifiedFiles.Add(filePath); } // Skip all projects that are not affected by the commit at all if (!isAffectedByCommit) continue; // Retrieve the change log information about this project ProjectChangeInfo changeInfo; if (!changesPerProject.TryGetValue(project, out changeInfo)) { changeInfo = new ProjectChangeInfo { Project = project, }; changesPerProject.Add(project, changeInfo); } // Add modified files foreach (string filePath in localModifiedFiles) { changeInfo.ModifiedFilePaths.Add(filePath); } // Add changelog entries, if we have meaningful comments if (!string.IsNullOrEmpty(commit.Title) && !string.IsNullOrEmpty(commit.Message)) { string[] msgItems = commit.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); changeInfo.Titles.Add(commit.Title); changeInfo.ChangeLog.AddRange(msgItems); } } } // For every non-default project, check if there was a non-default-project dependency // modified and add a version bump change. This will make sure sample projects // will always depend on the latest released version of their core and editor projects. foreach (ProjectInfo dependency in changesPerProject.Keys.ToArray()) { if (dependency.IsDefaultPackage) continue; foreach (ProjectInfo dependent in allProjects) { if (dependent.IsDefaultPackage) continue; if (!dependent.NuSpecDependencies.Contains(dependency.NuSpecPackageId)) continue; if (changesPerProject.ContainsKey(dependent)) continue; // Create a new change info for the dependent project ProjectChangeInfo changeInfo; changeInfo = new ProjectChangeInfo { Project = dependent }; changesPerProject.Add(dependent, changeInfo); // Add a dummy change log about this project changeInfo.Titles.Add("Updated Dependencies"); changeInfo.ChangeLog.Add(string.Format("#CHANGE: Updated {0} dependency", dependency.NuSpecPackageId)); } } return changesPerProject.Values.ToList(); }