diff --git a/JiraTimeBotForm/CommitWorks/BuzzwordReplacer.cs b/JiraTimeBotForm/CommitWorks/BuzzwordReplacer.cs deleted file mode 100644 index a56cccd..0000000 --- a/JiraTimeBotForm/CommitWorks/BuzzwordReplacer.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace JiraTimeBotForm.CommitWorks -{ - public class BuzzwordReplacer - { - public string FixBuzzwords(string commitMessage) - { - Dictionary buzzReplace = new Dictionary() - { - {"fix", "исправление"}, - {"up", "обновил"}, - {"init", "начало"}, - {"build", "сборка"}, - {"namespace", "неймспейс"} - }; - - foreach (var buzzReplaceItm in buzzReplace) - { - commitMessage = ReplaceCaseInsensitive(commitMessage, $" {buzzReplaceItm.Key} ", $" {buzzReplaceItm.Value} "); - commitMessage = ReplaceCaseInsensitive(commitMessage, $" {buzzReplaceItm.Key}.", $" {buzzReplaceItm.Value}."); - commitMessage = ReplaceCaseInsensitive(commitMessage, $" {buzzReplaceItm.Key},", $" {buzzReplaceItm.Value},"); - if (commitMessage.StartsWith($"{buzzReplaceItm.Key}", StringComparison.InvariantCultureIgnoreCase)) - { - commitMessage = ReplaceCaseInsensitive(commitMessage, $"{buzzReplaceItm.Key} ", $"{buzzReplaceItm.Value} "); - } - } - - return commitMessage; - } - - private string ReplaceCaseInsensitive(string input, string search, string replacement){ - string result = Regex.Replace( - input, - Regex.Escape(search), - replacement.Replace("$","$$"), - RegexOptions.IgnoreCase - ); - return result; - } - - } -} diff --git a/JiraTimeBotForm/JiraTimeBotForm.csproj b/JiraTimeBotForm/JiraTimeBotForm.csproj index 6f7c7c1..fc9fa84 100644 --- a/JiraTimeBotForm/JiraTimeBotForm.csproj +++ b/JiraTimeBotForm/JiraTimeBotForm.csproj @@ -71,7 +71,6 @@ - diff --git a/JiraTimeBotForm/Job.cs b/JiraTimeBotForm/Job.cs index c05918c..fcc507a 100644 --- a/JiraTimeBotForm/Job.cs +++ b/JiraTimeBotForm/Job.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; -using JiraTimeBotForm.CommitWorks; using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Mercurial; using JiraTimeBotForm.TaskProcessors; diff --git a/JiraTimeBotForm/Mercurial/MercurialCommitItem.cs b/JiraTimeBotForm/Mercurial/MercurialCommitItem.cs index 9dae37c..6866c3f 100644 --- a/JiraTimeBotForm/Mercurial/MercurialCommitItem.cs +++ b/JiraTimeBotForm/Mercurial/MercurialCommitItem.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace JiraTimeBotForm.Mercurial { @@ -10,8 +6,7 @@ namespace JiraTimeBotForm.Mercurial { public string Description { get; set; } public string Branch { get; set; } - - public DateTime StartTime { get; set; } - public DateTime EndTime { get; set; } + public DateTime Time { get; set; } + public int FilesAffected { get; set; } } } diff --git a/JiraTimeBotForm/Mercurial/MercurialLog.cs b/JiraTimeBotForm/Mercurial/MercurialLog.cs index 54318e2..576547d 100644 --- a/JiraTimeBotForm/Mercurial/MercurialLog.cs +++ b/JiraTimeBotForm/Mercurial/MercurialLog.cs @@ -4,9 +4,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading; -using System.Threading.Tasks; using JiraTimeBotForm.Configuration; -using JiraTimeBotForm.TaskTime; using Mercurial; namespace JiraTimeBotForm.Mercurial @@ -61,14 +59,13 @@ namespace JiraTimeBotForm.Mercurial continue; } commitMessage = StripTechnicalInfo(commitMessage); - //commitMessage = _buzzwordReplacer.FixBuzzwords(commitMessage); workTasks.Add(new MercurialCommitItem { Description = commitMessage, Branch = changeset.Branch, - StartTime = changeset.Timestamp, - EndTime = changeset.Timestamp + Time = changeset.Timestamp, + FilesAffected = changeset.PathActions.Count }); _log?.Trace($" - Найден changeset: {changeset.Timestamp} - {changeset.Branch} - {changeset.AuthorEmailAddress} - {commitMessage}"); } diff --git a/JiraTimeBotForm/TaskTime/ITaskTimeDiscoverer.cs b/JiraTimeBotForm/TaskTime/ITaskTimeDiscoverer.cs index e6b5b48..e230c17 100644 --- a/JiraTimeBotForm/TaskTime/ITaskTimeDiscoverer.cs +++ b/JiraTimeBotForm/TaskTime/ITaskTimeDiscoverer.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading; using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Mercurial; diff --git a/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs b/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs index 8ed5df2..83ea0d1 100644 --- a/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs +++ b/JiraTimeBotForm/TaskTime/TaskTimeDiscoverer.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Text; using System.Threading; using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Mercurial; -using Mercurial; namespace JiraTimeBotForm.TaskTime { @@ -38,7 +36,7 @@ namespace JiraTimeBotForm.TaskTime int currentTaskTime = (int)RoundTo(settings.MinuterPerWorkDay / totalCommitsCount * currentTaskCommits); remainMinutes = remainMinutes - currentTaskTime; - var orderedTasks = taskGroup.OrderBy(f => f.StartTime).ToArray(); + var orderedTasks = taskGroup.OrderBy(f => f.Time).ToArray(); StringBuilder sb = new StringBuilder(); foreach (var task in orderedTasks) { @@ -52,8 +50,8 @@ namespace JiraTimeBotForm.TaskTime Commits = taskGroup.Count(), Description = sb.ToString(), - StartTime = orderedTasks.First().StartTime, - EndTime = orderedTasks.Last().StartTime + StartTime = orderedTasks.First().Time, + EndTime = orderedTasks.Last().Time }; workTimeItems.Add(taskTimeItem); diff --git a/JiraTimeBotForm/frmMain.cs b/JiraTimeBotForm/frmMain.cs index 8126658..c8f4526 100644 --- a/JiraTimeBotForm/frmMain.cs +++ b/JiraTimeBotForm/frmMain.cs @@ -4,7 +4,6 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using JiraTimeBotForm.CommitWorks; using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Mercurial; using JiraTimeBotForm.Passwords; @@ -21,12 +20,10 @@ namespace JiraTimeBotForm { private readonly string _settingsPath; private readonly ILog _log; - private readonly NotifyIcon trayIcon; - private readonly ContextMenu trayMenu; + private readonly NotifyIcon _trayIcon; private Job _job; private readonly IReadOnlyList _controls; private CancellationTokenSource _tokenSource; - private BuzzwordReplacer _buzzwordReplacer; private CancellationTokenSource GetTokenSource() { @@ -45,12 +42,11 @@ namespace JiraTimeBotForm InitializeComponent(); _settingsPath = Path.Combine(Application.UserAppDataPath, "settings.json"); _log = new Logger(txtLog); - _buzzwordReplacer = new BuzzwordReplacer(); - trayMenu = new ContextMenu(); + var trayMenu = new ContextMenu(); trayMenu.MenuItems.Add("Exit", OnExit); - trayIcon = new NotifyIcon + _trayIcon = new NotifyIcon { Text = "JiraTimeBot", Icon = this.Icon, @@ -58,8 +54,8 @@ namespace JiraTimeBotForm Visible = false, }; - trayIcon.Click += btnTray_Click; - trayIcon.DoubleClick += btnTray_Click; + _trayIcon.Click += btnTray_Click; + _trayIcon.DoubleClick += btnTray_Click; var mercurialLog = new MercurialLog(_log); var taskTimeDiscoverer = new TaskTimeDiscoverer(_log); @@ -70,7 +66,7 @@ namespace JiraTimeBotForm private void frmMain_FormClosing(object sender, FormClosingEventArgs e) { - trayIcon.Visible = false; + _trayIcon.Visible = false; } private void OnExit(object sender, EventArgs e) @@ -176,13 +172,13 @@ namespace JiraTimeBotForm { if (FormWindowState.Minimized == this.WindowState) { - trayIcon.Visible = true; + _trayIcon.Visible = true; this.Hide(); } else if (FormWindowState.Normal == this.WindowState) { - trayIcon.Visible = false; + _trayIcon.Visible = false; } }