public ProjectHelper(MarkdownFlavorConverter markdownConverter) { Checker.IsNull(markdownConverter, "markdownConverter"); this.markdownConverter = markdownConverter; }
public static void Main(string[] args) { var githubOrganizationName = "???"; var githubRepositoryName = "???"; var projectPath = @"C:\Users\Guilherme\Desktop\jira-to-github"; var issuePath = Path.Combine(projectPath, "issues"); var projectFileFullPath = Path.Combine(projectPath, "project.json"); var milestonesPath = Path.Combine(projectPath, "milestones.json"); var labelsPath = Path.Combine(projectPath, "labels.json"); var jiraClientApi = new JiraClientApi("username", "password") { ViewChangelog = true }; var markdownConverter = new MarkdownFlavorConverter(); var projectUtil = new ProjectHelper(markdownConverter); ProjectDetail projectDetail = null; /*var jiraIssue = jiraClientApi.GetIssue("***"); var issue = projectUtil.ConvertToIssue(jiraIssue); Console.WriteLine(issue.JiraKey);*/ /*Log("INFO: Getting all project information..."); projectDetail = RetrieveProjectDescription("***", jiraClientApi, projectUtil); Log("INFO: Saving project information!"); File.WriteAllText(projectFileFullPath, projectDetail.ToJson()); Log("INFO: Project information saved with success!");*/ /*Log("INFO: Getting all issues information..."); projectDetail = File.ReadAllText(projectFileFullPath).ToObject<ProjectDetail>(); SaveIssuesInformation(projectDetail.IssueKeys, jiraClientApi, projectUtil, issuePath);*/ projectDetail = File.ReadAllText(projectFileFullPath).ToObject<ProjectDetail>(); var client = new GitHubClient(new ProductHeaderValue("jira-migrator")) { Credentials = new Credentials("username", "password") }; var migrator = new Migrator(projectUtil, client, githubOrganizationName, githubRepositoryName) { Logger = Log }; List<MilestoneGitHub> milestones = null; List<LabelGitHub> labels = null; if (!File.Exists(milestonesPath)) { var mls = migrator.MigrateToMilestones(projectDetail.Sprints); File.WriteAllText(milestonesPath, mls.ToJson()); } if (!File.Exists(labelsPath)) { var lbs = migrator.MigrateToLabels(projectDetail.Labels); File.WriteAllText(labelsPath, lbs.ToJson()); } milestones = File.ReadAllText(milestonesPath).ToObject<List<MilestoneGitHub>>(); labels = File.ReadAllText(labelsPath).ToObject<List<LabelGitHub>>(); Log("Info: Creating all issues."); foreach (var issueKey in projectDetail.IssueKeys) { var fileName = Path.Combine(issuePath, issueKey + ".txt"); var jiraIssue = File.ReadAllText(fileName).ToObject<MigrateJiraIssuesToGithub.Models.Issue>(); Octokit.Issue newIssue = null; SleepForMigrateIssue(); while (!migrator.TryMigrateToIssue(jiraIssue, milestones, labels, ref newIssue)) { Log(String.Format("WARNING: issue key {0} is blocked by github.", jiraIssue.JiraKey)); SleepForMigrateIssue(); } Log(String.Format("INFO: jira issue#{0} is created to github issue#{1}", jiraIssue.JiraKey, newIssue.Number)); } Log("Info: Issues are created with success."); Log("INFO: success!"); Log("Press any key to exit."); Console.ReadKey(); }