public static SemanticReleaseNotes GenerateReleaseNotes(Context context,
            IRepository gitRepo, IIssueTracker issueTracker, SemanticReleaseNotes previousReleaseNotes,
            Categories categories, TaggedCommit tagToStartFrom, ReleaseInfo currentReleaseInfo)
        {
            var releases = ReleaseFinder.FindReleases(gitRepo, tagToStartFrom, currentReleaseInfo);
            var findIssuesSince =
                IssueStartDateBasedOnPreviousReleaseNotes(gitRepo, previousReleaseNotes)
                ??
                tagToStartFrom.Commit.Author.When;

            var closedIssues = issueTracker.GetClosedIssues(context.IssueTracker, findIssuesSince).ToArray();

            var semanticReleases = (
                from release in releases
                let releaseNoteItems = closedIssues
                    .Where(i => (release.When == null || i.DateClosed < release.When) && (release.PreviousReleaseDate == null || i.DateClosed > release.PreviousReleaseDate))
                    .Select(i => new ReleaseNoteItem(i.Title, i.Id, i.HtmlUrl, i.Labels, i.DateClosed, i.Contributors))
                    .ToList<IReleaseNoteLine>()
                let beginningSha = release.FirstCommit == null ? null : release.FirstCommit.Substring(0, 10)
                let endSha = release.LastCommit == null ? null : release.LastCommit.Substring(0, 10)
                select new SemanticRelease(release.Name, release.When, releaseNoteItems, new ReleaseDiffInfo
                {
                    BeginningSha = beginningSha,
                    EndSha = endSha,
                    //DiffUrlFormat = issueTracker.DiffUrlFormat
                })).ToList();

            return new SemanticReleaseNotes(semanticReleases, categories).Merge(previousReleaseNotes);
        }
        public static SemanticReleaseNotes GenerateReleaseNotes(
            IRepository gitRepo, IIssueTracker issueTracker, SemanticReleaseNotes previousReleaseNotes,
            Categories categories, TaggedCommit tagToStartFrom, ReleaseInfo currentReleaseInfo,
            string diffUrlFormat)
        {
            var releases        = ReleaseFinder.FindReleases(gitRepo, tagToStartFrom, currentReleaseInfo);
            var findIssuesSince =
                IssueStartDateBasedOnPreviousReleaseNotes(gitRepo, previousReleaseNotes)
                ??
                tagToStartFrom.Commit.Author.When;

            var closedIssues = issueTracker.GetClosedIssues(findIssuesSince).ToArray();

            var semanticReleases = (
                from release in releases
                let releaseNoteItems = closedIssues
                                       .Where(i => (release.When == null || i.DateClosed < release.When) && (release.PreviousReleaseDate == null || i.DateClosed > release.PreviousReleaseDate))
                                       .Select(i => new ReleaseNoteItem(i.Title, i.Id, i.HtmlUrl, i.Labels, i.DateClosed, i.Contributors))
                                       .ToList <IReleaseNoteLine>()
                                       let beginningSha = release.FirstCommit == null ? null : release.FirstCommit.Substring(0, 10)
                                                          let endSha = release.LastCommit == null ? null : release.LastCommit.Substring(0, 10)
                                                                       select new SemanticRelease(release.Name, release.When, releaseNoteItems, new ReleaseDiffInfo
            {
                BeginningSha = beginningSha,
                EndSha = endSha,
                DiffUrlFormat = diffUrlFormat
            })).ToList();

            return(new SemanticReleaseNotes(semanticReleases, categories).Merge(previousReleaseNotes));
        }
Exemplo n.º 3
0
        public void Build(out IRepository repo, out IIssueTracker issueTracker)
        {
            var commits      = new List <Commit>();
            var tags         = new List <Tag>();
            var closedIssues = new List <OnlineIssue>();

            repo         = Substitute.For <IRepository>();
            issueTracker = Substitute.For <IIssueTracker>();

            commits.Add(CreateCommit(_initialCommitTime));
            var currentDate = _initialCommitTime.AddDays(1);

            foreach (var release in _releases)
            {
                // Create a commit, which *fixes* all the closed issues in the release
                commits.Add(CreateCommit(currentDate));

                // Create closed issues
                foreach (var issue in release.Item2)
                {
                    issue.DateClosed = currentDate;
                    closedIssues.Add(issue);
                }

                // Create commit which completes the release, and tag that commit
                currentDate = currentDate.AddDays(1);
                var commit = CreateCommit(currentDate);
                commits.Add(commit);
                tags.Add(CreateTag(commit, release.Item1));
                currentDate = currentDate.AddDays(1);
            }
            foreach (var additionalIssue in _additionalIssues)
            {
                closedIssues.Add(new OnlineIssue
                {
                    Id         = GetNextId(),
                    Title      = additionalIssue,
                    DateClosed = currentDate,
                    IssueType  = IssueType.Issue
                });
                var commit = CreateCommit(currentDate);
                commits.Add(commit);
            }

            SubstituteCommitLog(repo, commits, tags);
            issueTracker
            .GetClosedIssues(Arg.Any <DateTimeOffset?>())
            .Returns(c => closedIssues.Where(i => c.Arg <DateTimeOffset?>() == null || i.DateClosed > c.Arg <DateTimeOffset?>()));
        }
        public void Build(out IRepository repo, out IIssueTracker issueTracker)
        {
            var commits = new List<Commit>();
            var tags = new List<Tag>();
            var closedIssues = new List<OnlineIssue>();
            repo = Substitute.For<IRepository>();
            issueTracker = Substitute.For<IIssueTracker>();

            commits.Add(CreateCommit(_initialCommitTime));
            var currentDate = _initialCommitTime.AddDays(1);

            foreach (var release in _releases)
            {
                // Create a commit, which *fixes* all the closed issues in the release
                commits.Add(CreateCommit(currentDate));

                // Create closed issues
                foreach (var issue in release.Item2)
                {
                    issue.DateClosed = currentDate;
                    closedIssues.Add(issue);
                }

                // Create commit which completes the release, and tag that commit
                currentDate = currentDate.AddDays(1);
                var commit = CreateCommit(currentDate);
                commits.Add(commit);
                tags.Add(CreateTag(commit, release.Item1));
                currentDate = currentDate.AddDays(1);
            }
            foreach (var additionalIssue in _additionalIssues)
            {
                closedIssues.Add(new OnlineIssue
                {
                    Id = GetNextId(),
                    Title = additionalIssue,
                    DateClosed = currentDate,
                    IssueType = IssueType.Issue
                });
                var commit = CreateCommit(currentDate);
                commits.Add(commit);
            }

            SubstituteCommitLog(repo, commits, tags);
            issueTracker
                .GetClosedIssues(Arg.Any<DateTimeOffset?>())
                .Returns(c => closedIssues.Where(i => c.Arg<DateTimeOffset?>() == null || i.DateClosed > c.Arg<DateTimeOffset?>()));
        }