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 ReleaseNotesGenerator(Context context, IFileSystem fileSystem, IIssueTrackerFactory issueTrackerFactory) { _context = context; _fileSystem = fileSystem; _issueTrackerFactory = issueTrackerFactory; }
private static IGitRepositoryContextFactory GetRepositoryFactory(bool isRemote, string workingDir, Context context, IFileSystem fileSystem) { IGitRepositoryContextFactory gitRepoFactory = null; if (isRemote) { // clone repo from the remote url var cloneRepoArgs = new GitRemoteRepositoryContextFactory.RemoteRepoArgs(); cloneRepoArgs.Url = context.Repository.Url; cloneRepoArgs.Branch = context.Repository.Branch; var credentials = new UsernamePasswordCredentials(); credentials.Username = context.Repository.Username; credentials.Password = context.Repository.Password; cloneRepoArgs.Credentials = credentials; cloneRepoArgs.DestinationPath = workingDir; Log.WriteLine("Cloning a git repo from {0}", cloneRepoArgs.Url); gitRepoFactory = new GitRemoteRepositoryContextFactory(cloneRepoArgs, fileSystem); } else { gitRepoFactory = new GitLocalRepositoryContextFactory(workingDir, fileSystem); } return gitRepoFactory; }
private GitRepositoryContext GetRepository(Context context, IFileSystem fileSystem) { var workingDir = _fileSystem.GetRepositoryWorkingDirectory(context); var isRemote = !string.IsNullOrWhiteSpace(context.Repository.Url); var repoFactory = GetRepositoryFactory(isRemote, workingDir, context, fileSystem); var repo = repoFactory.GetRepositoryContext(); return repo; }
public static Context ToContext(this GitReleaseNotesArguments arguments) { IIssueTrackerContext issueTrackerContext; switch (arguments.IssueTracker) { case IssueTracker.BitBucket: var bitBucketContext = new BitBucketContext { }; issueTrackerContext = bitBucketContext; break; case IssueTracker.GitHub: var gitHubContext = new GitHubContext { }; issueTrackerContext = gitHubContext; break; case IssueTracker.Jira: var jiraContext = new JiraContext { Jql = arguments.IssueTrackerFilter }; issueTrackerContext = jiraContext; break; case IssueTracker.YouTrack: var youTrackContext = new YouTrackContext { Filter = arguments.IssueTrackerFilter }; issueTrackerContext = youTrackContext; break; default: throw new ArgumentOutOfRangeException(); } issueTrackerContext.Url = arguments.IssueTrackerUrl; issueTrackerContext.Username = arguments.IssueTrackerUsername; issueTrackerContext.Password = arguments.IssueTrackerPassword; issueTrackerContext.Token = arguments.IssueTrackerToken; issueTrackerContext.ProjectId = arguments.IssueTrackerProjectId; var context = new Context(issueTrackerContext); context.WorkingDirectory = arguments.WorkingDirectory; context.Verbose = arguments.Verbose; context.OutputFile = arguments.OutputFile; context.Categories = arguments.Categories; context.Version = arguments.Version; context.AllTags = arguments.AllTags; context.AllLabels = arguments.AllLabels; var repository = context.Repository; repository.Url = arguments.RepoUrl; repository.Branch = arguments.RepoBranch; repository.Username = arguments.RepoUsername; repository.Password = arguments.RepoPassword; repository.Token = arguments.RepoToken; return context; }