<commit_before>﻿
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;

using Octokit;

using CodePlexIssueMigrator.CodePlex;

namespace CodePlexIssueMigrator.GitHub
{
	public class GitHubWorker
	{
		/// <summary>GitHub API Client.</summary>
		private GitHubClient _gitHubClient;

		/// <summary>Command line arguments.</summary>
		private readonly CommandLineOptions _options;

		public GitHubWorker(CommandLineOptions options)
		{
			_options = options;

			var credentials = new Credentials(_options.GitHubAccessToken);
			var connection = new Connection(new ProductHeaderValue("CodeplexIssueMigrator")) { Credentials = credentials };
			_gitHubClient = new GitHubClient(connection);
		}

		public async Task Run(IEnumerable<CodePlexIssue> issues)
		{
			foreach (var issue in issues)
			{
				await CreateIssue(issue);
			}
		}

		public async Task RunFor(CodePlexIssue issue)
		{
			await CreateIssue(issue);
		}


		private async Task CreateIssue(CodePlexIssue codePlexIssue)
		{
			var codePlexIssueUrl = string.Format("http://{0}.codeplex.com/workitem/{1}", _options.CodeplexProject, codePlexIssue.Id);
			var description = new StringBuilder();
			description.AppendFormat("**This issue was imported from [CodePlex]({0})**", codePlexIssueUrl);
			description.AppendLine();
			description.AppendLine();
			description.AppendFormat(CultureInfo.InvariantCulture, "**[{0}](http://www.codeplex.com/site/users/view/{0})** wrote {1:yyyy-MM-dd} at {1:HH:mm}\r\n", codePlexIssue.ReportedBy, codePlexIssue.Time);
			description.Append(codePlexIssue.Description);
			foreach (var comment in codePlexIssue.Comments)
			{
				description.AppendLine();
				description.AppendLine();
				description.AppendFormat(CultureInfo.InvariantCulture, "**[{0}](http://www.codeplex.com/site/users/view/{0})** wrote {1:yyyy-MM-dd} at {1:HH:mm}\r\n", comment.Author, comment.Time);
				description.Append(comment.Content);
				// await CreateComment(gitHubIssue.Number, comment.Content);
			}

			var labels = new List<string>();

			if (codePlexIssue.Type == "Feature")
			{<commit_msg>Make "imported from" message small<commit_after>﻿
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;

using Octokit;

using CodePlexIssueMigrator.CodePlex;

namespace CodePlexIssueMigrator.GitHub
{
	public class GitHubWorker
	{
		/// <summary>GitHub API Client.</summary>
		private GitHubClient _gitHubClient;

		/// <summary>Command line arguments.</summary>
		private readonly CommandLineOptions _options;

		public GitHubWorker(CommandLineOptions options)
		{
			_options = options;

			var credentials = new Credentials(_options.GitHubAccessToken);
			var connection = new Connection(new ProductHeaderValue("CodeplexIssueMigrator")) { Credentials = credentials };
			_gitHubClient = new GitHubClient(connection);
		}

		public async Task Run(IEnumerable<CodePlexIssue> issues)
		{
			foreach (var issue in issues)
			{
				await CreateIssue(issue);
			}
		}

		public async Task RunFor(CodePlexIssue issue)
		{
			await CreateIssue(issue);
		}


		private async Task CreateIssue(CodePlexIssue codePlexIssue)
		{
			var codePlexIssueUrl = string.Format("http://{0}.codeplex.com/workitem/{1}", _options.CodeplexProject, codePlexIssue.Id);
			var description = new StringBuilder();
			description.AppendFormat("<sub>This issue was imported from [CodePlex]({0})</sub>", codePlexIssueUrl);
			description.AppendLine();
			description.AppendLine();
			description.AppendFormat(CultureInfo.InvariantCulture, "**[{0}](http://www.codeplex.com/site/users/view/{0})** wrote {1:yyyy-MM-dd} at {1:HH:mm}\r\n", codePlexIssue.ReportedBy, codePlexIssue.Time);
			description.Append(codePlexIssue.Description);
			foreach (var comment in codePlexIssue.Comments)
			{
				description.AppendLine();
				description.AppendLine();
				description.AppendFormat(CultureInfo.InvariantCulture, "**[{0}](http://www.codeplex.com/site/users/view/{0})** wrote {1:yyyy-MM-dd} at {1:HH:mm}\r\n", comment.Author, comment.Time);
				description.Append(comment.Content);
				// await CreateComment(gitHubIssue.Number, comment.Content);
			}

			var labels = new List<string>();

			if (codePlexIssue.Type == "Feature")
			{
{'fraction_non_alphanumeric': 0.12833099579242638, 'fraction_numerical': 0.005142589995324918, 'mean_word_length': 4.893939393939394, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2126338', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1311, 'n_words': 258}