Пример #1
0
        protected override ChangeLogTaskResult Run(ApplicationChangeLog changeLog)
        {
            if (!changeLog.Versions.Any())
            {
                m_Logger.LogWarning("Changelog is empty, skipping parsing of commit messages");
                return(ChangeLogTaskResult.Skipped);
            }

            m_Logger.LogInformation("Parsing commit messages");

            var sortedVersions = changeLog.Versions
                                 .OrderByDescending(x => x.Version)
                                 .ToArray();

            for (var i = 0; i < sortedVersions.Length; i++)
            {
                var current  = sortedVersions[i];
                var previous = i + 1 < sortedVersions.Length ? sortedVersions[i + 1] : null;

                var commits = m_Repository.GetCommits(previous?.Commit, current.Commit);

                foreach (var commit in commits)
                {
                    if (TryGetChangeLogEntry(commit, out var entry))
                    {
                        m_Logger.LogDebug($"Adding changelog entry for commit '{commit.Id}' to version '{current.Version}'");
                        changeLog[current].Add(entry);
                    }
                }
            }

            return(ChangeLogTaskResult.Success);
        }
Пример #2
0
        protected override ChangeLogTaskResult Run(ApplicationChangeLog changeLog)
        {
            if (!changeLog.Versions.Any())
            {
                m_Logger.LogWarning("Changelog is empty, skipping loading of commit messages");
                return(ChangeLogTaskResult.Skipped);
            }

            m_Logger.LogInformation("Loading commits");

            var sortedVersions = changeLog.Versions
                                 .OrderByDescending(x => x.Version)
                                 .ToArray();

            for (var i = 0; i < sortedVersions.Length; i++)
            {
                var current  = sortedVersions[i];
                var previous = i + 1 < sortedVersions.Length ? sortedVersions[i + 1] : null;

                IReadOnlyList <GitCommit> commits;
                if (previous is null)
                {
                    m_Logger.LogDebug($"Adding all commits up to '{current.Commit.Id}' to version '{current.Version.Version}'");
                    commits = m_Repository.GetCommits(null, current.Commit);
                }
                else
                {
                    m_Logger.LogDebug($"Adding commits between '{previous.Commit.Id}' and '{current.Commit.Id}' to version '{current.Version.Version}'");
                    commits = m_Repository.GetCommits(previous.Commit, current.Commit);
                }

                foreach (var commit in commits)
                {
                    changeLog[current].Add(commit);
                }
            }

            return(ChangeLogTaskResult.Success);
        }