Compare commits

..
8 Commits
6 changed files with 94 additions and 50 deletions
+1 -1
View File
@@ -1 +1 @@
1.0.83 1.0.88
@@ -25,6 +25,7 @@ namespace JiraTimeBot.Configuration
public string JiraQuery { get; set; } public string JiraQuery { get; set; }
public string TimeControlTask { get; set; } public string TimeControlTask { get; set; }
public int RandomWorkMinutes { get; set; } public int RandomWorkMinutes { get; set; }
public string AlternativeEmail { get; set; }
public static Settings LoadAndCheck(Action settingsSource, Action<string> errorMessageReporter) public static Settings LoadAndCheck(Action settingsSource, Action<string> errorMessageReporter)
{ {
+31 -31
View File
@@ -1,31 +1,31 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("JiraTimeBot")] [assembly: AssemblyTitle("JiraTimeBot")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JiraTimeBot")] [assembly: AssemblyProduct("JiraTimeBot")]
[assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // 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 // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM // The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")] [assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.83")] [assembly: AssemblyVersion("1.0.88")]
[assembly: AssemblyFileVersion("1.0.83")] [assembly: AssemblyFileVersion("1.0.88")]
[assembly: AssemblyInformationalVersion("1.0.83")] [assembly: AssemblyInformationalVersion("1.0.88")]
+30 -10
View File
@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
namespace JiraTimeBot.RepositoryProviders namespace JiraTimeBot.RepositoryProviders
@@ -35,7 +36,7 @@ namespace JiraTimeBot.RepositoryProviders
date = date.GetValueOrDefault(DateTime.Now.Date); date = date.GetValueOrDefault(DateTime.Now.Date);
var workTasks = new List<TaskTimeItem>(); var workTasks = new List<TaskTimeItem>();
foreach (var repoDirectory in Directory.GetDirectories(settings.RepositoryPath)) foreach (var repoDirectory in Directory.GetDirectories(settings.RepositoryPath, ".git", SearchOption.AllDirectories))
{ {
if (cancellationToken.IsCancellationRequested) if (cancellationToken.IsCancellationRequested)
{ {
@@ -43,16 +44,15 @@ namespace JiraTimeBot.RepositoryProviders
} }
//var project = new DirectoryInfo(repoDirectory).Name; //var project = new DirectoryInfo(repoDirectory).Name;
if (!Directory.Exists(Path.Combine(repoDirectory, ".git"))) var repoRootDirectory = repoDirectory.Replace(".git", "");
var directoryInfo = new DirectoryInfo(repoRootDirectory);
if (!directoryInfo.Exists)
{ {
continue; continue;
} }
var directoryInfo = new DirectoryInfo(repoDirectory);
var repo = new LibGit2Sharp.Repository(repoDirectory);
var repo = new LibGit2Sharp.Repository(repoRootDirectory);
if (settings.PullBeforeProcess) if (settings.PullBeforeProcess)
{ {
try try
@@ -78,7 +78,14 @@ namespace JiraTimeBot.RepositoryProviders
var reflog = repo.Refs.Log(repo.Refs.Head); var reflog = repo.Refs.Log(repo.Refs.Head);
foreach (var reflogItem in reflog) foreach (var reflogItem in reflog)
{ {
if (reflogItem.Committer.When.Date != date.Value.Date || reflogItem.Committer.Email != settings.MercurialAuthorEmail)
var dateMatch = date.Value.Date == reflogItem.Committer.When.Date;
var committerEmail = reflogItem.Committer.Email;
var userMatch = committerEmail.Equals(settings.MercurialAuthorEmail, StringComparison.CurrentCultureIgnoreCase)
|| committerEmail.Equals(settings.AlternativeEmail, StringComparison.CurrentCultureIgnoreCase);
if (!dateMatch || !userMatch)
{ {
continue; continue;
} }
@@ -96,18 +103,31 @@ namespace JiraTimeBot.RepositoryProviders
{ {
return new List<TaskTimeItem>(); return new List<TaskTimeItem>();
} }
if (commit.Author.When.DateTime.Date != date.Value.Date || commit.Author.Email != settings.MercurialAuthorEmail)
var userMatch = commit.Author.Email.Equals(settings.MercurialAuthorEmail, StringComparison.CurrentCultureIgnoreCase)
|| commit.Author.Email.Equals(settings.AlternativeEmail, StringComparison.CurrentCultureIgnoreCase);
if (commit.Author.When.DateTime.Date != date.Value.Date
|| !userMatch)
{ {
continue; continue;
} }
var branch = ListBranchesContaininingCommit(repo, commit.Sha).Select(f => f.FriendlyName) var regex = new Regex("[a-zA-Z0-9]{1,4}-[0-9]{1,6}");
.Where(f => f.Contains("-") && !f.Contains("/")).Distinct().FirstOrDefault(); var branch = ListBranchesContaininingCommit(repo, commit.Sha)
.Select(f => f.FriendlyName)
.FirstOrDefault(f => regex.IsMatch(f));
//.Where(f => f.Contains("-") && !f.Contains("/")).Distinct().FirstOrDefault();
if (branch == null) if (branch == null)
{ {
continue; continue;
} }
branch = regex.Match(branch).Value;
var commitMessage = commit.MessageShort; var commitMessage = commit.MessageShort;
commitMessage = _technicalInfoSkipper.StripBranchPrefix(branch, commitMessage); commitMessage = _technicalInfoSkipper.StripBranchPrefix(branch, commitMessage);
+28 -6
View File
@@ -57,6 +57,8 @@
this.lblJiraUrl = new System.Windows.Forms.Label(); this.lblJiraUrl = new System.Windows.Forms.Label();
this.txtJiraUrl = new System.Windows.Forms.TextBox(); this.txtJiraUrl = new System.Windows.Forms.TextBox();
this.chkRemoveManuallyAddedWorklogs = new System.Windows.Forms.CheckBox(); this.chkRemoveManuallyAddedWorklogs = new System.Windows.Forms.CheckBox();
this.tbAlternateEmail = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// label5 // label5
@@ -146,7 +148,7 @@
// chkAddComments // chkAddComments
// //
this.chkAddComments.AutoSize = true; this.chkAddComments.AutoSize = true;
this.chkAddComments.Location = new System.Drawing.Point(65, 366); this.chkAddComments.Location = new System.Drawing.Point(65, 400);
this.chkAddComments.Name = "chkAddComments"; this.chkAddComments.Name = "chkAddComments";
this.chkAddComments.Size = new System.Drawing.Size(133, 17); this.chkAddComments.Size = new System.Drawing.Size(133, 17);
this.chkAddComments.TabIndex = 31; this.chkAddComments.TabIndex = 31;
@@ -155,7 +157,7 @@
// //
// btnSave // btnSave
// //
this.btnSave.Location = new System.Drawing.Point(86, 432); this.btnSave.Location = new System.Drawing.Point(86, 466);
this.btnSave.Name = "btnSave"; this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(75, 23); this.btnSave.Size = new System.Drawing.Size(75, 23);
this.btnSave.TabIndex = 32; this.btnSave.TabIndex = 32;
@@ -221,7 +223,7 @@
// chkAutostart // chkAutostart
// //
this.chkAutostart.AutoSize = true; this.chkAutostart.AutoSize = true;
this.chkAutostart.Location = new System.Drawing.Point(65, 343); this.chkAutostart.Location = new System.Drawing.Point(65, 377);
this.chkAutostart.Name = "chkAutostart"; this.chkAutostart.Name = "chkAutostart";
this.chkAutostart.Size = new System.Drawing.Size(96, 17); this.chkAutostart.Size = new System.Drawing.Size(96, 17);
this.chkAutostart.TabIndex = 40; this.chkAutostart.TabIndex = 40;
@@ -263,7 +265,7 @@
// chkPullBeforeProcess // chkPullBeforeProcess
// //
this.chkPullBeforeProcess.AutoSize = true; this.chkPullBeforeProcess.AutoSize = true;
this.chkPullBeforeProcess.Location = new System.Drawing.Point(65, 409); this.chkPullBeforeProcess.Location = new System.Drawing.Point(65, 443);
this.chkPullBeforeProcess.Name = "chkPullBeforeProcess"; this.chkPullBeforeProcess.Name = "chkPullBeforeProcess";
this.chkPullBeforeProcess.Size = new System.Drawing.Size(83, 17); this.chkPullBeforeProcess.Size = new System.Drawing.Size(83, 17);
this.chkPullBeforeProcess.TabIndex = 45; this.chkPullBeforeProcess.TabIndex = 45;
@@ -307,18 +309,36 @@
// chkRemoveManuallyAddedWorklogs // chkRemoveManuallyAddedWorklogs
// //
this.chkRemoveManuallyAddedWorklogs.AutoSize = true; this.chkRemoveManuallyAddedWorklogs.AutoSize = true;
this.chkRemoveManuallyAddedWorklogs.Location = new System.Drawing.Point(65, 387); this.chkRemoveManuallyAddedWorklogs.Location = new System.Drawing.Point(65, 421);
this.chkRemoveManuallyAddedWorklogs.Name = "chkRemoveManuallyAddedWorklogs"; this.chkRemoveManuallyAddedWorklogs.Name = "chkRemoveManuallyAddedWorklogs";
this.chkRemoveManuallyAddedWorklogs.Size = new System.Drawing.Size(157, 17); this.chkRemoveManuallyAddedWorklogs.Size = new System.Drawing.Size(157, 17);
this.chkRemoveManuallyAddedWorklogs.TabIndex = 48; this.chkRemoveManuallyAddedWorklogs.TabIndex = 48;
this.chkRemoveManuallyAddedWorklogs.Text = "Удалять \"ручные записи\""; this.chkRemoveManuallyAddedWorklogs.Text = "Удалять \"ручные записи\"";
this.chkRemoveManuallyAddedWorklogs.UseVisualStyleBackColor = true; this.chkRemoveManuallyAddedWorklogs.UseVisualStyleBackColor = true;
// //
// tbAlternateEmail
//
this.tbAlternateEmail.Location = new System.Drawing.Point(133, 328);
this.tbAlternateEmail.Name = "tbAlternateEmail";
this.tbAlternateEmail.Size = new System.Drawing.Size(100, 20);
this.tbAlternateEmail.TabIndex = 49;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(4, 331);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(123, 13);
this.label10.TabIndex = 50;
this.label10.Text = "Дополнительный Email";
//
// frmSettings // frmSettings
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(243, 467); this.ClientSize = new System.Drawing.Size(243, 496);
this.Controls.Add(this.label10);
this.Controls.Add(this.tbAlternateEmail);
this.Controls.Add(this.chkRemoveManuallyAddedWorklogs); this.Controls.Add(this.chkRemoveManuallyAddedWorklogs);
this.Controls.Add(this.lblJiraUrl); this.Controls.Add(this.lblJiraUrl);
this.Controls.Add(this.txtJiraUrl); this.Controls.Add(this.txtJiraUrl);
@@ -390,5 +410,7 @@
private System.Windows.Forms.Label lblJiraUrl; private System.Windows.Forms.Label lblJiraUrl;
private System.Windows.Forms.TextBox txtJiraUrl; private System.Windows.Forms.TextBox txtJiraUrl;
private System.Windows.Forms.CheckBox chkRemoveManuallyAddedWorklogs; private System.Windows.Forms.CheckBox chkRemoveManuallyAddedWorklogs;
private System.Windows.Forms.TextBox tbAlternateEmail;
private System.Windows.Forms.Label label10;
} }
} }
+3 -2
View File
@@ -43,7 +43,7 @@ namespace JiraTimeBot.UI
txtRandomMinutes.Text = settings.RandomWorkMinutes.ToString(); txtRandomMinutes.Text = settings.RandomWorkMinutes.ToString();
chkPullBeforeProcess.Checked = settings.PullBeforeProcess; chkPullBeforeProcess.Checked = settings.PullBeforeProcess;
chkRemoveManuallyAddedWorklogs.Checked = settings.RemoveManuallyAddedWorklogs; chkRemoveManuallyAddedWorklogs.Checked = settings.RemoveManuallyAddedWorklogs;
tbAlternateEmail.Text = settings.AlternativeEmail;
cboWorkType_SelectedIndexChanged(null, null); cboWorkType_SelectedIndexChanged(null, null);
} }
@@ -78,7 +78,8 @@ namespace JiraTimeBot.UI
MinuterPerWorkDay = minuterPerWorkDay, MinuterPerWorkDay = minuterPerWorkDay,
RandomWorkMinutes = randomWorkMinutes, RandomWorkMinutes = randomWorkMinutes,
PullBeforeProcess = chkPullBeforeProcess.Checked, PullBeforeProcess = chkPullBeforeProcess.Checked,
RemoveManuallyAddedWorklogs = chkRemoveManuallyAddedWorklogs.Checked RemoveManuallyAddedWorklogs = chkRemoveManuallyAddedWorklogs.Checked,
AlternativeEmail = tbAlternateEmail.Text
}; };
//LockUnlock(false); //LockUnlock(false);