мелкие изменнеия

This commit is contained in:
Danil Kislov
2019-03-15 16:50:46 +03:00
parent 90be288737
commit fd02201b42
8 changed files with 16 additions and 78 deletions
@@ -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<string, string> buzzReplace = new Dictionary<string, string>()
{
{"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;
}
}
}
-1
View File
@@ -71,7 +71,6 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CommitWorks\BuzzwordReplacer.cs" />
<Compile Include="Extensions\Extensions.cs" /> <Compile Include="Extensions\Extensions.cs" />
<Compile Include="Job.cs" /> <Compile Include="Job.cs" />
<Compile Include="Logger.cs" /> <Compile Include="Logger.cs" />
-1
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JiraTimeBotForm.CommitWorks;
using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Configuration;
using JiraTimeBotForm.Mercurial; using JiraTimeBotForm.Mercurial;
using JiraTimeBotForm.TaskProcessors; using JiraTimeBotForm.TaskProcessors;
@@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JiraTimeBotForm.Mercurial namespace JiraTimeBotForm.Mercurial
{ {
@@ -10,8 +6,7 @@ namespace JiraTimeBotForm.Mercurial
{ {
public string Description { get; set; } public string Description { get; set; }
public string Branch { get; set; } public string Branch { get; set; }
public DateTime Time { get; set; }
public DateTime StartTime { get; set; } public int FilesAffected { get; set; }
public DateTime EndTime { get; set; }
} }
} }
+2 -5
View File
@@ -4,9 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Configuration;
using JiraTimeBotForm.TaskTime;
using Mercurial; using Mercurial;
namespace JiraTimeBotForm.Mercurial namespace JiraTimeBotForm.Mercurial
@@ -61,14 +59,13 @@ namespace JiraTimeBotForm.Mercurial
continue; continue;
} }
commitMessage = StripTechnicalInfo(commitMessage); commitMessage = StripTechnicalInfo(commitMessage);
//commitMessage = _buzzwordReplacer.FixBuzzwords(commitMessage);
workTasks.Add(new MercurialCommitItem workTasks.Add(new MercurialCommitItem
{ {
Description = commitMessage, Description = commitMessage,
Branch = changeset.Branch, Branch = changeset.Branch,
StartTime = changeset.Timestamp, Time = changeset.Timestamp,
EndTime = changeset.Timestamp FilesAffected = changeset.PathActions.Count
}); });
_log?.Trace($" - Найден changeset: {changeset.Timestamp} - {changeset.Branch} - {changeset.AuthorEmailAddress} - {commitMessage}"); _log?.Trace($" - Найден changeset: {changeset.Timestamp} - {changeset.Branch} - {changeset.AuthorEmailAddress} - {commitMessage}");
} }
@@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Configuration;
using JiraTimeBotForm.Mercurial; using JiraTimeBotForm.Mercurial;
@@ -1,12 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Configuration;
using JiraTimeBotForm.Mercurial; using JiraTimeBotForm.Mercurial;
using Mercurial;
namespace JiraTimeBotForm.TaskTime namespace JiraTimeBotForm.TaskTime
{ {
@@ -38,7 +36,7 @@ namespace JiraTimeBotForm.TaskTime
int currentTaskTime = (int)RoundTo(settings.MinuterPerWorkDay / totalCommitsCount * currentTaskCommits); int currentTaskTime = (int)RoundTo(settings.MinuterPerWorkDay / totalCommitsCount * currentTaskCommits);
remainMinutes = remainMinutes - currentTaskTime; remainMinutes = remainMinutes - currentTaskTime;
var orderedTasks = taskGroup.OrderBy(f => f.StartTime).ToArray(); var orderedTasks = taskGroup.OrderBy(f => f.Time).ToArray();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
foreach (var task in orderedTasks) foreach (var task in orderedTasks)
{ {
@@ -52,8 +50,8 @@ namespace JiraTimeBotForm.TaskTime
Commits = taskGroup.Count(), Commits = taskGroup.Count(),
Description = sb.ToString(), Description = sb.ToString(),
StartTime = orderedTasks.First().StartTime, StartTime = orderedTasks.First().Time,
EndTime = orderedTasks.Last().StartTime EndTime = orderedTasks.Last().Time
}; };
workTimeItems.Add(taskTimeItem); workTimeItems.Add(taskTimeItem);
+8 -12
View File
@@ -4,7 +4,6 @@ using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using JiraTimeBotForm.CommitWorks;
using JiraTimeBotForm.Configuration; using JiraTimeBotForm.Configuration;
using JiraTimeBotForm.Mercurial; using JiraTimeBotForm.Mercurial;
using JiraTimeBotForm.Passwords; using JiraTimeBotForm.Passwords;
@@ -21,12 +20,10 @@ namespace JiraTimeBotForm
{ {
private readonly string _settingsPath; private readonly string _settingsPath;
private readonly ILog _log; private readonly ILog _log;
private readonly NotifyIcon trayIcon; private readonly NotifyIcon _trayIcon;
private readonly ContextMenu trayMenu;
private Job _job; private Job _job;
private readonly IReadOnlyList<Control> _controls; private readonly IReadOnlyList<Control> _controls;
private CancellationTokenSource _tokenSource; private CancellationTokenSource _tokenSource;
private BuzzwordReplacer _buzzwordReplacer;
private CancellationTokenSource GetTokenSource() private CancellationTokenSource GetTokenSource()
{ {
@@ -45,12 +42,11 @@ namespace JiraTimeBotForm
InitializeComponent(); InitializeComponent();
_settingsPath = Path.Combine(Application.UserAppDataPath, "settings.json"); _settingsPath = Path.Combine(Application.UserAppDataPath, "settings.json");
_log = new Logger(txtLog); _log = new Logger(txtLog);
_buzzwordReplacer = new BuzzwordReplacer();
trayMenu = new ContextMenu(); var trayMenu = new ContextMenu();
trayMenu.MenuItems.Add("Exit", OnExit); trayMenu.MenuItems.Add("Exit", OnExit);
trayIcon = new NotifyIcon _trayIcon = new NotifyIcon
{ {
Text = "JiraTimeBot", Text = "JiraTimeBot",
Icon = this.Icon, Icon = this.Icon,
@@ -58,8 +54,8 @@ namespace JiraTimeBotForm
Visible = false, Visible = false,
}; };
trayIcon.Click += btnTray_Click; _trayIcon.Click += btnTray_Click;
trayIcon.DoubleClick += btnTray_Click; _trayIcon.DoubleClick += btnTray_Click;
var mercurialLog = new MercurialLog(_log); var mercurialLog = new MercurialLog(_log);
var taskTimeDiscoverer = new TaskTimeDiscoverer(_log); var taskTimeDiscoverer = new TaskTimeDiscoverer(_log);
@@ -70,7 +66,7 @@ namespace JiraTimeBotForm
private void frmMain_FormClosing(object sender, FormClosingEventArgs e) private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{ {
trayIcon.Visible = false; _trayIcon.Visible = false;
} }
private void OnExit(object sender, EventArgs e) private void OnExit(object sender, EventArgs e)
@@ -176,13 +172,13 @@ namespace JiraTimeBotForm
{ {
if (FormWindowState.Minimized == this.WindowState) if (FormWindowState.Minimized == this.WindowState)
{ {
trayIcon.Visible = true; _trayIcon.Visible = true;
this.Hide(); this.Hide();
} }
else if (FormWindowState.Normal == this.WindowState) else if (FormWindowState.Normal == this.WindowState)
{ {
trayIcon.Visible = false; _trayIcon.Visible = false;
} }
} }