diff --git a/GitUI/NBugReports/BugReportForm.cs b/GitUI/NBugReports/BugReportForm.cs
index 11115fe4b8f..4a60b80a11b 100644
--- a/GitUI/NBugReports/BugReportForm.cs
+++ b/GitUI/NBugReports/BugReportForm.cs
@@ -10,6 +10,7 @@
using System;
using System.Diagnostics;
using System.Drawing;
+using System.Text.RegularExpressions;
using System.Windows.Forms;
using GitExtUtils.GitUI;
using GitUI.NBugReports.Info;
@@ -30,6 +31,7 @@ public partial class BugReportForm : GitExtensionsForm
private readonly TranslationString _toolTipCopy = new TranslationString("Copy the issue details into clipboard");
private readonly TranslationString _toolTipSendQuit = new TranslationString("Report the issue to GitHub and quit application.\r\nA valid GitHub account is required");
private readonly TranslationString _toolTipQuit = new TranslationString("Quit application without reporting the issue");
+ private readonly TranslationString _noReproStepsSuppliedErrorMessage = new TranslationString(@"Please provide as much as information as possible to help the developers solve this issue.");
private static readonly IErrorReportMarkDownBodyBuilder ErrorReportBodyBuilder;
private static readonly GitHubUrlBuilder UrlBuilder;
@@ -97,6 +99,18 @@ public DialogResult ShowDialog(Exception exception, string environmentInfo)
return result;
}
+ protected override void OnShown(EventArgs e)
+ {
+ base.OnShown(e);
+ descriptionTextBox.Focus();
+ }
+
+ private bool CheckContainsInfo(string input)
+ {
+ var text = Regex.Replace(input, @"\s*|\r|\n", string.Empty);
+ return !string.IsNullOrWhiteSpace(text);
+ }
+
private void QuitButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Abort;
@@ -105,6 +119,14 @@ private void QuitButton_Click(object sender, EventArgs e)
private void SendAndQuitButton_Click(object sender, EventArgs e)
{
+ var hasUserText = CheckContainsInfo(descriptionTextBox.Text);
+ if (!hasUserText)
+ {
+ MessageBox.Show(this, _noReproStepsSuppliedErrorMessage.Text, _title.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ descriptionTextBox.Focus();
+ return;
+ }
+
if (MessageBox.Show(this, _submitGitHubMessage.Text, _title.Text,
MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
{
@@ -130,5 +152,20 @@ private void btnCopy_Click(object sender, EventArgs e)
DialogResult = DialogResult.None;
}
+
+ internal TestAccessor GetTestAccessor()
+ => new TestAccessor(this);
+
+ public readonly struct TestAccessor
+ {
+ private readonly BugReportForm _form;
+
+ public TestAccessor(BugReportForm form)
+ {
+ _form = form;
+ }
+
+ public bool CheckContainsInfo(string input) => _form.CheckContainsInfo(input);
+ }
}
}
\ No newline at end of file
diff --git a/UnitTests/GitUITests/GitUITests.csproj b/UnitTests/GitUITests/GitUITests.csproj
index ca55dc97bd6..98f4f985f0a 100644
--- a/UnitTests/GitUITests/GitUITests.csproj
+++ b/UnitTests/GitUITests/GitUITests.csproj
@@ -64,6 +64,7 @@
+
diff --git a/UnitTests/GitUITests/NBugReports/BugReportFormTests.cs b/UnitTests/GitUITests/NBugReports/BugReportFormTests.cs
new file mode 100644
index 00000000000..0ef76ee2b2b
--- /dev/null
+++ b/UnitTests/GitUITests/NBugReports/BugReportFormTests.cs
@@ -0,0 +1,28 @@
+using System.Threading;
+using FluentAssertions;
+using GitUI.NBugReports;
+using NUnit.Framework;
+
+namespace GitUITests.NBugReports
+{
+ [Apartment(ApartmentState.STA)]
+ [TestFixture]
+ public class BugReportFormTests
+ {
+ private BugReportForm _form;
+
+ [SetUp]
+ public void Setup()
+ {
+ _form = new BugReportForm();
+ }
+
+ [TestCase("", false)]
+ [TestCase("\t\r\n\t\t \r \n \r", false)]
+ [TestCase("\t\r\n\t\t a \r \n \r", true)]
+ public void Test(string input, bool expected)
+ {
+ _form.GetTestAccessor().CheckContainsInfo(input).Should().Be(expected);
+ }
+ }
+}
\ No newline at end of file