Skip to content

Commit 32f917e

Browse files
committedNov 5, 2018
Fix issues identified by running TranslationApp
1 parent 10cfe8b commit 32f917e

File tree

10 files changed

+47
-24
lines changed

10 files changed

+47
-24
lines changed
 

‎GitUI/CommandsDialogs/EnvironmentInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public partial class EnvironmentInfo : UserControl
88
{
99
public EnvironmentInfo()
1010
{
11-
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
11+
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime || GitModuleForm.IsUnitTestActive)
1212
{
1313
UserEnvironmentInformation.Initialise(
1414
"9999999999999999999999999999999999abcdef", true);

‎GitUI/CommandsDialogs/FormAbout.Designer.cs

+16-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎GitUI/CommandsDialogs/FormAbout.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public FormAbout()
2323

2424
// Click handlers
2525
_NO_TRANSLATE_labelProductName.LinkClicked += (s, e) => { Process.Start(@"http://github.com/gitextensions/gitextensions"); };
26-
thanksTo.LinkClicked += delegate { ShowContributorsForm(); };
26+
_NO_TRANSLATE_ThanksTo.LinkClicked += delegate { ShowContributorsForm(); };
2727
pictureDonate.Click += delegate { Process.Start(FormDonate.DonationUrl); };
2828
linkLabelIcons.LinkClicked += delegate { Process.Start("http://p.yusukekamiyamane.com/"); };
2929

@@ -54,7 +54,7 @@ void ThankNextContributor()
5454
// Select a contributor at random
5555
var contributorName = contributorsList[random.Next(contributorsList.Count - 1)].Trim();
5656

57-
thanksTo.Text = thanksToContributorsText + contributorName;
57+
_NO_TRANSLATE_ThanksTo.Text = thanksToContributorsText + contributorName;
5858
}
5959

6060
IReadOnlyList<string> GetContributorList()

‎GitUI/CommandsDialogs/FormFileHistory.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ protected override void Dispose(bool disposing)
136136
if (disposing)
137137
{
138138
_asyncLoader.Dispose();
139-
_filterRevisionsHelper.Dispose();
140-
_filterBranchHelper.Dispose();
141-
_formBrowseMenus.Dispose();
139+
140+
// if the form was instantiated by the translation app, all of the following would be null
141+
_filterRevisionsHelper?.Dispose();
142+
_filterBranchHelper?.Dispose();
143+
_formBrowseMenus?.Dispose();
142144

143145
components?.Dispose();
144146
}

‎GitUI/CommandsDialogs/SettingsDialog/Pages/GeneralSettingsPage.cs

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.ComponentModel;
23
using System.IO;
34
using System.Linq;
45
using GitCommands;
@@ -14,6 +15,11 @@ public GeneralSettingsPage()
1415
Text = "General";
1516
InitializeComplete();
1617

18+
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime || GitModuleForm.IsUnitTestActive)
19+
{
20+
return;
21+
}
22+
1723
ThreadHelper.JoinableTaskFactory.Run(async () =>
1824
{
1925
var repositoryHistory = await RepositoryHistoryManager.Locals.LoadRecentHistoryAsync();

‎GitUI/GitModuleForm.cs

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public class GitModuleForm : GitExtensionsForm, IGitUICommandsSource
1515
/// <inheritdoc />
1616
public event EventHandler<GitUICommandsChangedEventArgs> UICommandsChanged;
1717

18+
/// <summary>
19+
/// Indicates that the process is run by unit tests runner.
20+
/// </summary>
1821
internal static bool IsUnitTestActive { get; set; }
1922

2023
[CanBeNull] private GitUICommands _uiCommands;

‎GitUI/Properties/AssemblyInfo.cs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Runtime.CompilerServices;
22

33
[assembly: InternalsVisibleTo("GitUITests")]
4+
[assembly: InternalsVisibleTo("TranslationApp")]
45
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // required for NSubstitute for mocking internal members

‎GitUI/Translation/UpdateLocalEnglishTranslations.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pushd $PSScriptRoot
2+
13
Write-Host "Copying the latest English translation before the update..."
24
$translationsFolder = Resolve-Path .\
35
$releaseTranslationsFolder = Resolve-Path ..\..\GitExtensions\bin\Release\Translation
@@ -8,6 +10,10 @@ $src = Resolve-Path ..\..\GitExtensions\bin\Release
810
pushd "$src"
911
Write-Host "Updating the English translation..."
1012
Start-Process -FilePath "$src\TranslationApp.exe" -ArgumentList "update" -Wait
13+
if ($LASTEXITCODE -ne 0) {
14+
popd
15+
exit -1
16+
}
1117
popd
1218

1319
Write-Host "Copying the updated English translation to commit..."

‎Plugins/Bitbucket/BitbucketPullRequestForm.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public partial class BitbucketPullRequestForm : GitExtensionsFormBase
2222
[CanBeNull] private readonly Settings _settings;
2323
private readonly BindingList<BitbucketUser> _reviewers = new BindingList<BitbucketUser>();
2424

25-
public BitbucketPullRequestForm(Settings settings)
25+
public BitbucketPullRequestForm([CanBeNull] Settings settings)
2626
{
2727
InitializeComponent();
2828

2929
// NOTE ddlBranchSource and ddlBranchTarget both have string items so do not need a display member
3030
ddlRepositorySource.DisplayMember = nameof(Repository.DisplayName);
3131
ddlRepositoryTarget.DisplayMember = nameof(Repository.DisplayName);
3232

33-
_settings = settings;
33+
_settings = settings ?? new Settings();
3434

3535
Load += delegate
3636
{

‎TranslationApp/Program.cs

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ private static void UpdateAllTranslations()
6969
{
7070
using (new WaitCursorScope())
7171
{
72+
// we will be instantiating a number of forms using their default .ctors
73+
// this would lead to InvalidOperationException thrown in GitModuleForm()
74+
// set the flag that will stop this from happening
75+
GitModuleForm.IsUnitTestActive = true;
76+
7277
var neutralItems = TranslationHelpers.LoadNeutralItems();
7378
string filename = Path.Combine(Translator.GetTranslationDir(), "English.xlf");
7479
TranslationHelpers.SaveTranslation(null, neutralItems, filename);

0 commit comments

Comments
 (0)
Please sign in to comment.