private static void CreateIssueTrackers(IRepository repository, GitReleaseNotesArguments arguments) { var log = new Log(); _issueTrackers = new Dictionary <IssueTracker, IIssueTracker> { { IssueTracker.GitHub, new GitHubIssueTracker(repository, () => { var gitHubClient = new GitHubClient(new Octokit.ProductHeaderValue("GitReleaseNotes")); if (arguments.Token != null) { gitHubClient.Credentials = new Credentials(arguments.Token); } return(gitHubClient); }, log, arguments) }, { IssueTracker.Jira, new JiraIssueTracker(new JiraApi(), log, arguments) }, { IssueTracker.YouTrack, new YouTrackIssueTracker(new YouTrackApi(), log, arguments) }, { IssueTracker.BitBucket, new BitBucketIssueTracker(repository, new BitBucketApi(), log, arguments) } }; }
private static void CreateIssueTrackers(IRepository repository, GitReleaseNotesArguments arguments) { _issueTrackers = new Dictionary<IssueTracker, IIssueTracker> { { IssueTracker.GitHub, new GitHubIssueTracker(repository, () => { var gitHubClient = new GitHubClient(new ProductHeaderValue("GitReleaseNotes")); if (arguments.Token != null) { gitHubClient.Credentials = new Credentials(arguments.Token); } return gitHubClient; }, new Log(), arguments) }, { IssueTracker.Jira, new JiraIssueTracker(new JiraApi(), arguments) }, { IssueTracker.YouTrack, new YouTrackIssueTracker(new YouTrackApi(), arguments) } }; }
public static ReleaseNotesGenerationParameters ToContext(this GitReleaseNotesArguments arguments) { return(new ReleaseNotesGenerationParameters { WorkingDirectory = arguments.WorkingDirectory ?? Directory.GetCurrentDirectory(), Categories = arguments.Categories, Version = arguments.Version, AllTags = arguments.AllTags, AllLabels = arguments.AllLabels, RepositorySettings = { Url = arguments.RepoUrl, Branch = arguments.RepoBranch, Authentication = { Username = arguments.RepoUsername, Password = arguments.RepoPassword, Token = arguments.RepoToken } }, IssueTracker = { Server = arguments.IssueTrackerUrl, ProjectId = arguments.IssueTrackerProjectId, Type = arguments.IssueTracker, Authentication = { Username = arguments.IssueTrackerUsername, Password = arguments.IssueTrackerPassword, Token = arguments.IssueTrackerToken } } }); }
private static void CreateIssueTrackers(GitReleaseNotesArguments arguments) { var gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests")) { Credentials = new Credentials(arguments.Token) }; IssueTrackers = new Dictionary<IssueTracker, IIssueTracker> { {IssueTracker.GitHub, new GitHubIssueTracker(new IssueNumberExtractor(), gitHubClient)} }; }
public static bool VerifyArguments(GitReleaseNotesArguments arguments) { if (string.IsNullOrEmpty(arguments.OutputFile) && !arguments.Publish) { Console.WriteLine("WARN: No Output file specified (*.md) [/OutputFile ...]"); } if (!string.IsNullOrEmpty(arguments.OutputFile) && !arguments.OutputFile.EndsWith(".md")) { Console.WriteLine("WARN: Output file should have a .md extension [/OutputFile ...]"); arguments.OutputFile = null; } return true; }
public static bool VerifyArguments(GitReleaseNotesArguments arguments) { if (string.IsNullOrEmpty(arguments.OutputFile)) { Console.WriteLine("WARN: No Output file specified (*.md) [/OutputFile ...]"); } if (!string.IsNullOrEmpty(arguments.OutputFile) && !arguments.OutputFile.EndsWith(".md")) { Console.WriteLine("WARN: Output file should have a .md extension [/OutputFile ...]"); arguments.OutputFile = null; } return(true); }
public void WriteReleaseNotes(GitReleaseNotesArguments arguments, SemanticReleaseNotes releaseNotes) { var builder = new StringBuilder(); var categories = arguments.Categories == null ? _categories : _categories.Concat(arguments.Categories.Split(',')).ToArray(); foreach (var releaseNoteItem in releaseNotes.ReleaseNoteItems) { var taggedCategory = releaseNoteItem.Tags .FirstOrDefault(t => categories.Any(c => c.Equals(t, StringComparison.InvariantCultureIgnoreCase))); var title = releaseNoteItem.Title; var issueNumber = releaseNoteItem.IssueNumber; var htmlUrl = releaseNoteItem.HtmlUrl; if ("bug".Equals(taggedCategory, StringComparison.InvariantCultureIgnoreCase)) taggedCategory = "fix"; var category = taggedCategory == null ? null : string.Format(" +{0}", taggedCategory.Replace(" ", "-")); var item = string.Format(" - {0} [{1}]({2}){3}", title, issueNumber, htmlUrl, category); builder.AppendLine(item); } var outputFile = Path.IsPathRooted(arguments.OutputFile) ? arguments.OutputFile : Path.Combine(_workingDirectory, arguments.OutputFile); _fileSystem.WriteAllText(outputFile, builder.ToString()); }
private static void PublishReleaseIfNeeded(string releaseNotesOutput, GitReleaseNotesArguments arguments, IIssueTracker issueTracker) { if (!arguments.Publish) return; Console.WriteLine("Publishing release {0} to {1}", arguments.Version, arguments.IssueTracker); issueTracker.PublishRelease(releaseNotesOutput); }
public static bool VerifyArguments(GitReleaseNotesArguments arguments) { VerifyOutputFile(arguments.OutputFile); VerifyOutputFileHtml(arguments.OutputFileHtml); return(true); }