public static List <GitChangelogItem> ParseCommitMessages(GitCommit message, ChangelogSettings settings) { List <GitChangelogItem> items = new List <GitChangelogItem>(); var defaultCategory = settings.Categories.FirstOrDefault(c => c.IsDefault)?.DisplayName; var summaryCategory = settings.Categories.FirstOrDefault(c => c.IsSummary)?.DisplayName; foreach (var line in message.GetMessageLines()) { var messageLine = new GitCommitMessageLine(line); GitChangelogItem cm = new GitChangelogItem(); cm.Commit = message; var category = GetCategory(settings, cm, messageLine) ?? defaultCategory; if (string.IsNullOrEmpty(category)) { continue; } if (!string.IsNullOrEmpty(summaryCategory) && category.Equals(summaryCategory)) { cm.PartOfSummary = true; } cm.Category = category; cm.Links = GetLinkText(settings, cm, messageLine); cm.Message = GetMessage(settings, cm, messageLine); items.Add(cm); } return(items); }
public static List <GitCommit> GetCommitBetweenTags(ChangelogSettings settings, string versionName, string from, string to) { using (var repo = new Repository(settings.GitRepoLocation)) { object fromTag = null; object toTag = null; if (string.IsNullOrEmpty(from)) { fromTag = repo.Branches[settings.LatestCodeBranch]; } else { fromTag = repo.Tags[from]; } if (string.IsNullOrEmpty(to)) { toTag = repo.Branches[settings.LatestCodeBranch]; } else { toTag = repo.Tags[to]; } if (fromTag == null || toTag == null) { throw new Exception($"Failed to find tags - from: {fromTag} to: {toTag}"); } CommitFilter filter = null; if (string.IsNullOrEmpty(from)) { filter = new CommitFilter { IncludeReachableFrom = toTag }; } else { filter = new CommitFilter { ExcludeReachableFrom = fromTag, IncludeReachableFrom = toTag }; } var commits = repo.Commits.QueryBy(filter); return(commits.Select(c => GitCommit.Create(versionName, c)).ToList()); } }