From 24887e1c46dbaefe549b120145c4f3553c7ac49b Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 26 Aug 2020 12:44:50 +0300 Subject: [PATCH] Add alternative email to check commits in git --- src/JiraTimeBot/Configuration/Settings.cs | 1 + src/JiraTimeBot/RepositoryProviders/GitLog.cs | 13 +++++-- src/JiraTimeBot/UI/frmSettings.Designer.cs | 34 +++++++++++++++---- src/JiraTimeBot/UI/frmSettings.cs | 5 +-- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/JiraTimeBot/Configuration/Settings.cs b/src/JiraTimeBot/Configuration/Settings.cs index 358533d..acb56e6 100644 --- a/src/JiraTimeBot/Configuration/Settings.cs +++ b/src/JiraTimeBot/Configuration/Settings.cs @@ -25,6 +25,7 @@ namespace JiraTimeBot.Configuration public string JiraQuery { get; set; } public string TimeControlTask { get; set; } public int RandomWorkMinutes { get; set; } + public string AlternativeEmail { get; set; } public static Settings LoadAndCheck(Action settingsSource, Action errorMessageReporter) { diff --git a/src/JiraTimeBot/RepositoryProviders/GitLog.cs b/src/JiraTimeBot/RepositoryProviders/GitLog.cs index 026e13d..ded511c 100644 --- a/src/JiraTimeBot/RepositoryProviders/GitLog.cs +++ b/src/JiraTimeBot/RepositoryProviders/GitLog.cs @@ -80,7 +80,10 @@ namespace JiraTimeBot.RepositoryProviders { var dateMatch = date.Value.Date == reflogItem.Committer.When.Date; - var userMatch = reflogItem.Committer.Email.Equals(settings.MercurialAuthorEmail, StringComparison.CurrentCultureIgnoreCase); + var committerEmail = reflogItem.Committer.Email; + + var userMatch = committerEmail.Equals(settings.MercurialAuthorEmail, StringComparison.CurrentCultureIgnoreCase) + || committerEmail.Equals(settings.AlternativeEmail, StringComparison.CurrentCultureIgnoreCase); if (!dateMatch || !userMatch) { @@ -100,7 +103,13 @@ namespace JiraTimeBot.RepositoryProviders { return new List(); } - 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; } diff --git a/src/JiraTimeBot/UI/frmSettings.Designer.cs b/src/JiraTimeBot/UI/frmSettings.Designer.cs index a2afb6a..cf3f550 100644 --- a/src/JiraTimeBot/UI/frmSettings.Designer.cs +++ b/src/JiraTimeBot/UI/frmSettings.Designer.cs @@ -57,6 +57,8 @@ this.lblJiraUrl = new System.Windows.Forms.Label(); this.txtJiraUrl = new System.Windows.Forms.TextBox(); this.chkRemoveManuallyAddedWorklogs = new System.Windows.Forms.CheckBox(); + this.tbAlternateEmail = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label5 @@ -146,7 +148,7 @@ // chkAddComments // 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.Size = new System.Drawing.Size(133, 17); this.chkAddComments.TabIndex = 31; @@ -155,7 +157,7 @@ // // 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.Size = new System.Drawing.Size(75, 23); this.btnSave.TabIndex = 32; @@ -221,7 +223,7 @@ // chkAutostart // 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.Size = new System.Drawing.Size(96, 17); this.chkAutostart.TabIndex = 40; @@ -263,7 +265,7 @@ // chkPullBeforeProcess // 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.Size = new System.Drawing.Size(83, 17); this.chkPullBeforeProcess.TabIndex = 45; @@ -307,18 +309,36 @@ // chkRemoveManuallyAddedWorklogs // 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.Size = new System.Drawing.Size(157, 17); this.chkRemoveManuallyAddedWorklogs.TabIndex = 48; this.chkRemoveManuallyAddedWorklogs.Text = "Удалять \"ручные записи\""; 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 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.lblJiraUrl); this.Controls.Add(this.txtJiraUrl); @@ -390,5 +410,7 @@ private System.Windows.Forms.Label lblJiraUrl; private System.Windows.Forms.TextBox txtJiraUrl; private System.Windows.Forms.CheckBox chkRemoveManuallyAddedWorklogs; + private System.Windows.Forms.TextBox tbAlternateEmail; + private System.Windows.Forms.Label label10; } } \ No newline at end of file diff --git a/src/JiraTimeBot/UI/frmSettings.cs b/src/JiraTimeBot/UI/frmSettings.cs index 524c340..8bed3d9 100644 --- a/src/JiraTimeBot/UI/frmSettings.cs +++ b/src/JiraTimeBot/UI/frmSettings.cs @@ -43,7 +43,7 @@ namespace JiraTimeBot.UI txtRandomMinutes.Text = settings.RandomWorkMinutes.ToString(); chkPullBeforeProcess.Checked = settings.PullBeforeProcess; chkRemoveManuallyAddedWorklogs.Checked = settings.RemoveManuallyAddedWorklogs; - + tbAlternateEmail.Text = settings.AlternativeEmail; cboWorkType_SelectedIndexChanged(null, null); } @@ -78,7 +78,8 @@ namespace JiraTimeBot.UI MinuterPerWorkDay = minuterPerWorkDay, RandomWorkMinutes = randomWorkMinutes, PullBeforeProcess = chkPullBeforeProcess.Checked, - RemoveManuallyAddedWorklogs = chkRemoveManuallyAddedWorklogs.Checked + RemoveManuallyAddedWorklogs = chkRemoveManuallyAddedWorklogs.Checked, + AlternativeEmail = tbAlternateEmail.Text }; //LockUnlock(false);