From 364b23dbca13bd491d2b6fb91e0f6925f1901061 Mon Sep 17 00:00:00 2001 From: Danil Kislov Date: Tue, 2 Jul 2019 18:22:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .semver.txt | 2 +- .../JiraIntegration/JiraCommitEmulator.cs | 34 +++++----- src/JiraTimeBot/JiraTimeBot.csproj | 1 + src/JiraTimeBot/Mercurial/MercurialLog.cs | 17 +++-- src/JiraTimeBot/Properties/AssemblyInfo.cs | 62 +++++++++---------- .../TaskTime/Objects/CommitType.cs | 7 +++ .../TaskTime/Objects/TaskTimeItem.cs | 15 +++-- .../TaskTime/TaskTimeByCommitsCalculator.cs | 14 ++--- src/JiraTimeBot/TaskTime/TaskTimeSpread.cs | 27 ++++---- 9 files changed, 95 insertions(+), 84 deletions(-) create mode 100644 src/JiraTimeBot/TaskTime/Objects/CommitType.cs diff --git a/.semver.txt b/.semver.txt index c3ccccf..4bf1778 100644 --- a/.semver.txt +++ b/.semver.txt @@ -1 +1 @@ -1.0.59 +1.0.60 diff --git a/src/JiraTimeBot/JiraIntegration/JiraCommitEmulator.cs b/src/JiraTimeBot/JiraIntegration/JiraCommitEmulator.cs index 332592f..5a51b52 100644 --- a/src/JiraTimeBot/JiraIntegration/JiraCommitEmulator.cs +++ b/src/JiraTimeBot/JiraIntegration/JiraCommitEmulator.cs @@ -46,28 +46,26 @@ namespace JiraTimeBot.JiraIntegration { foreach (var comment in userComments.OrderBy(f=>f.CreatedDate)) { - workTasks.Add(new TaskTimeItem - { - StartTime = issue.Updated.GetValueOrDefault(date.Value), - Description = issue.Summary, - Branch = issue.Key.Value, - FilesAffected = 1, - Commits = 1, - Type = CommitType.Task - }); + var item = new TaskTimeItem(issue.Key.Value, + issue.Summary, + 1, + TimeSpan.Zero, + issue.Updated.GetValueOrDefault(date.Value), + 1, + CommitType.Task); + workTasks.Add(item); } } else { - workTasks.Add(new TaskTimeItem - { - StartTime = issue.Updated.GetValueOrDefault(date.Value), - Description = issue.Summary, - Branch = issue.Key.Value, - FilesAffected = 1, - Commits = 1, - Type = CommitType.Task - }); + var item = new TaskTimeItem(issue.Key.Value, + issue.Summary, + 1, + TimeSpan.Zero, + issue.Updated.GetValueOrDefault(date.Value), + 1, + CommitType.Task); + workTasks.Add(item); } } diff --git a/src/JiraTimeBot/JiraTimeBot.csproj b/src/JiraTimeBot/JiraTimeBot.csproj index 704343d..0bc50d7 100644 --- a/src/JiraTimeBot/JiraTimeBot.csproj +++ b/src/JiraTimeBot/JiraTimeBot.csproj @@ -92,6 +92,7 @@ + Form diff --git a/src/JiraTimeBot/Mercurial/MercurialLog.cs b/src/JiraTimeBot/Mercurial/MercurialLog.cs index 1c28173..2bdc3f7 100644 --- a/src/JiraTimeBot/Mercurial/MercurialLog.cs +++ b/src/JiraTimeBot/Mercurial/MercurialLog.cs @@ -72,16 +72,13 @@ namespace JiraTimeBot.Mercurial } commitMessage = _technicalInfoSkipper.StripTechnicalInfo(commitMessage); - var task = new TaskTimeItem - { - StartTime = changeset.Timestamp, - Description = commitMessage, - Branch = changeset.Branch, - FilesAffected = changeset.PathActions.Count, - Commits = 1, - TimeSpent = TimeSpan.Zero, - Type = GetCommitType(changeset.Branch) - }; + var task = new TaskTimeItem(changeset.Branch, + commitMessage, + 1, + TimeSpan.Zero, + changeset.Timestamp, + changeset.PathActions.Count, + GetCommitType(changeset.Branch)); if (task.Type == CommitType.Release && task.Description.StartsWith("Merge with", StringComparison.CurrentCultureIgnoreCase)) { diff --git a/src/JiraTimeBot/Properties/AssemblyInfo.cs b/src/JiraTimeBot/Properties/AssemblyInfo.cs index ba22032..c4e501d 100644 --- a/src/JiraTimeBot/Properties/AssemblyInfo.cs +++ b/src/JiraTimeBot/Properties/AssemblyInfo.cs @@ -1,31 +1,31 @@ -using System.Reflection; -using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("JiraTimeBot")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("JiraTimeBot")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")] -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.59")] -[assembly: AssemblyFileVersion("1.0.59")] -[assembly: AssemblyInformationalVersion("1.0.59")] +using System.Reflection; +using System.Runtime.InteropServices; +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("JiraTimeBot")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("JiraTimeBot")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")] +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.60")] +[assembly: AssemblyFileVersion("1.0.60")] +[assembly: AssemblyInformationalVersion("1.0.60")] diff --git a/src/JiraTimeBot/TaskTime/Objects/CommitType.cs b/src/JiraTimeBot/TaskTime/Objects/CommitType.cs new file mode 100644 index 0000000..9006884 --- /dev/null +++ b/src/JiraTimeBot/TaskTime/Objects/CommitType.cs @@ -0,0 +1,7 @@ +namespace JiraTimeBot.TaskTime.Objects +{ + public enum CommitType { + Task = 0, + Release = 1 + } +} \ No newline at end of file diff --git a/src/JiraTimeBot/TaskTime/Objects/TaskTimeItem.cs b/src/JiraTimeBot/TaskTime/Objects/TaskTimeItem.cs index 83d76fd..ef3e627 100644 --- a/src/JiraTimeBot/TaskTime/Objects/TaskTimeItem.cs +++ b/src/JiraTimeBot/TaskTime/Objects/TaskTimeItem.cs @@ -11,10 +11,17 @@ namespace JiraTimeBot.TaskTime.Objects public int Commits { get; set; } public int FilesAffected { get; set; } public CommitType Type { get; set; } - } - public enum CommitType { - Task = 0, - Release = 1 + public TaskTimeItem(string branch, string description, int commits, TimeSpan timeSpent, DateTime startTime, + int filesAffected, CommitType type) + { + Branch = branch; + Description = description; + Commits = commits; + TimeSpent = timeSpent; + StartTime = startTime; + FilesAffected = filesAffected; + Type = type; + } } } diff --git a/src/JiraTimeBot/TaskTime/TaskTimeByCommitsCalculator.cs b/src/JiraTimeBot/TaskTime/TaskTimeByCommitsCalculator.cs index ec25853..341fdb3 100644 --- a/src/JiraTimeBot/TaskTime/TaskTimeByCommitsCalculator.cs +++ b/src/JiraTimeBot/TaskTime/TaskTimeByCommitsCalculator.cs @@ -93,13 +93,13 @@ namespace JiraTimeBot.TaskTime //Если указана задача контроля времени - то спишем туда 30 минут и вычеркнем их из общего рабочего времени. if (!string.IsNullOrEmpty(timeControlTask)) { - return new TaskTimeItem - { - TimeSpent = TimeSpan.FromMinutes(minutes), - Branch = timeControlTask, - Commits = 1, - Description = "Ведение учета времени" - }; + return new TaskTimeItem(timeControlTask, + "Ведение учета времени", + 1, + TimeSpan.FromMinutes(minutes), + DateTime.Now, + 1, + CommitType.Task); } return null; diff --git a/src/JiraTimeBot/TaskTime/TaskTimeSpread.cs b/src/JiraTimeBot/TaskTime/TaskTimeSpread.cs index d379051..bad79c1 100644 --- a/src/JiraTimeBot/TaskTime/TaskTimeSpread.cs +++ b/src/JiraTimeBot/TaskTime/TaskTimeSpread.cs @@ -34,19 +34,20 @@ namespace JiraTimeBot.TaskTime { sb.AppendLine($"- {task.Description}"); } - var taskTimeItem = new TaskTimeItem - { - Branch = taskGroup.Key, - TimeSpent = appendTime ? - TimeSpan.FromMinutes(taskGroup.Sum(f=>f.TimeSpent.TotalMinutes)) + TimeSpan.FromMinutes(currentTaskTime): - TimeSpan.FromMinutes(currentTaskTime) - , - Commits = taskGroup.Sum(f=>f.Commits), - Description = sb.ToString(), - StartTime = taskGroup.Min(f=>f.StartTime), - FilesAffected = taskGroup.Sum(f=>f.FilesAffected), - Type = taskGroup.First().Type - }; + + var timeSpent = appendTime + ? TimeSpan.FromMinutes(taskGroup.Sum(f => f.TimeSpent.TotalMinutes)) + + TimeSpan.FromMinutes(currentTaskTime) + : TimeSpan.FromMinutes(currentTaskTime); + + var taskTimeItem = new TaskTimeItem( + taskGroup.Key, + sb.ToString(), + taskGroup.Sum(f => f.Commits), + timeSpent, + taskGroup.Min(f => f.StartTime), + taskGroup.Sum(f => f.FilesAffected), + taskGroup.First().Type); newList.Add(taskTimeItem); }