Skip to content

Commit e981c6a

Browse files
authored
Merge pull request #1 from mast-eu/FromMainRepo
Import Gerrit commit history from GE main repo
2 parents c30242b + 6d153e2 commit e981c6a

38 files changed

+3455
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<ItemGroup>
4+
<ProjectReference Include="..\..\..\Plugins\Gerrit\Gerrit.csproj" />
5+
<ProjectReference Include="..\..\..\ResourceManager\ResourceManager.csproj" />
6+
</ItemGroup>
7+
8+
</Project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
using CommonTestUtils;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("GerritTests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("GerritTests")]
13+
[assembly: AssemblyCopyright("Copyright © 2019")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("2f8f55f7-c82f-44fc-ab52-9d0c692996fc")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
37+
38+
[assembly: TestAppSettings]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Gerrit.Server;
7+
using NUnit.Framework;
8+
9+
namespace GerritTests.Server
10+
{
11+
public static class CommandBuilderWithDraftSupportTests
12+
{
13+
[TestCase("a, b, c", "fix-7521", ExpectedResult = "refs/for/fix-7521%r=a,r=b,r=c")]
14+
[TestCase("a|b|c", "fix-7521", ExpectedResult = "refs/for/fix-7521%r=a,r=b,r=c")]
15+
[TestCase("a b c", "fix-7521", ExpectedResult = "refs/for/fix-7521%r=a,r=b,r=c")]
16+
[TestCase("a; b;c", "fix-7521", ExpectedResult = "refs/for/fix-7521%r=a,r=b,r=c")]
17+
[TestCase("q", "fix-7521", ExpectedResult = "refs/for/fix-7521%r=q")]
18+
[TestCase("", "fix-7521", ExpectedResult = "refs/for/fix-7521")]
19+
[TestCase(null, "fix-7521", ExpectedResult = "refs/for/fix-7521")]
20+
public static string Build_WithReviewers_splits_reviewrs_and_builds_expected_command(string reviewer, string branch)
21+
{
22+
var sut = new CommandBuilderWithDraftSupport();
23+
return sut.WithReviewers(reviewer).Build(branch);
24+
}
25+
26+
[Test(ExpectedResult = "refs/drafts/master%r=a")]
27+
public static string Build_when_publishtype_is_drafts_builds_expected_command()
28+
{
29+
var sut = new CommandBuilderWithDraftSupport();
30+
return sut.WithReviewers("a").WithPublishType("drafts").Build("master");
31+
}
32+
33+
[Test(ExpectedResult = "refs/for/fix-7521")]
34+
public static string Build_with_all_values_on_default_builds_expected_command()
35+
{
36+
var sut = new CommandBuilderWithDraftSupport();
37+
return sut.WithReviewers(string.Empty)
38+
.WithCC(string.Empty)
39+
.WithTopic(string.Empty)
40+
.WithPublishType(string.Empty)
41+
.WithHashTag(string.Empty)
42+
.Build("fix-7521");
43+
}
44+
45+
[Test(ExpectedResult = "refs/for/fix-7521%r=mygroup,cc=team2,topic=ABC-123,hashtag=what")]
46+
public static string Build_with_values_for_all_options_builds_expected_command()
47+
{
48+
var sut = new CommandBuilderWithDraftSupport();
49+
return sut.WithReviewers("mygroup")
50+
.WithCC("team2")
51+
.WithTopic("ABC-123")
52+
.WithPublishType(string.Empty)
53+
.WithHashTag("what")
54+
.Build("fix-7521");
55+
}
56+
}
57+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Gerrit.Server;
7+
using NUnit.Framework;
8+
9+
namespace GerritTests.Server
10+
{
11+
public static class CommandBuilderWithPrivateSupportTests
12+
{
13+
[TestCase("", ExpectedResult = "refs/for/mybranch")]
14+
[TestCase("wip", ExpectedResult = "refs/for/mybranch%wip")]
15+
[TestCase("private", ExpectedResult = "refs/for/mybranch%private")]
16+
public static string Build_given_a_publishType_builds_expected_command(string publishType)
17+
{
18+
var sut = new CommandBuilderWithPrivateSupport();
19+
20+
return sut.WithPublishType(publishType).Build("mybranch");
21+
}
22+
23+
[Test]
24+
public static void Build_given_a_set_of_values_builds_expected_command()
25+
{
26+
var sut = new CommandBuilderWithPrivateSupport();
27+
28+
Assert.AreEqual("refs/for/master%r=myteam",
29+
sut.WithReviewers("myteam").WithPublishType(string.Empty).Build("master"));
30+
}
31+
}
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Linq;
2+
using Gerrit.Server;
3+
using NUnit.Framework;
4+
5+
namespace GerritTests.Server
6+
{
7+
public static class GerritCapabilityTests
8+
{
9+
[Test]
10+
public static void PublishTypes_for_Version2_15_has_expected_list_of_values()
11+
{
12+
RunTest(GerritCapabilities.Version2_15, new[] { "", "wip", "private" });
13+
}
14+
15+
[Test]
16+
public static void PublishTypes_for_OlderVersion_has_expected_list_of_values()
17+
{
18+
RunTest(GerritCapabilities.OldestVersion, new[] { "", "drafts" });
19+
}
20+
21+
private static void RunTest(GerritCapabilities capability, string[] expectedValues)
22+
{
23+
var publishTypes = capability.PublishTypes
24+
.Select(x => x.Value)
25+
.ToArray();
26+
27+
Assert.That(publishTypes, Is.EqualTo(expectedValues));
28+
}
29+
}
30+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using GitUI;
3+
using GitUIPluginInterfaces;
4+
5+
namespace Gerrit
6+
{
7+
public class FormGerritBase : GitExtensionsForm
8+
{
9+
protected GerritSettings Settings { get; private set; }
10+
protected readonly IGitUICommands UICommands;
11+
protected IGitModule Module => UICommands.GitModule;
12+
13+
private FormGerritBase()
14+
: this(null)
15+
{
16+
}
17+
18+
protected FormGerritBase(IGitUICommands uiCommands)
19+
: base(true)
20+
{
21+
UICommands = uiCommands;
22+
}
23+
24+
protected override void OnLoad(EventArgs e)
25+
{
26+
if (DesignMode)
27+
{
28+
return;
29+
}
30+
31+
Settings = GerritSettings.Load(Module);
32+
33+
if (Settings == null)
34+
{
35+
Dispose();
36+
return;
37+
}
38+
39+
base.OnLoad(e);
40+
}
41+
}
42+
}

src/GitExtensions.GerritPlugin/FormGerritChangeSubmitted.Designer.cs

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Diagnostics;
2+
using System.Windows.Forms;
3+
using GitUI;
4+
5+
namespace Gerrit
6+
{
7+
public partial class FormGerritChangeSubmitted : GitExtensionsForm
8+
{
9+
public FormGerritChangeSubmitted()
10+
{
11+
InitializeComponent();
12+
InitializeComplete();
13+
}
14+
15+
public static void ShowSubmitted(IWin32Window owner, string change)
16+
{
17+
var form = new FormGerritChangeSubmitted();
18+
19+
form._NO_TRANSLATE_TargetLabel.Text = change;
20+
form._NO_TRANSLATE_TargetLabel.Click += (s, e) => Process.Start(change);
21+
22+
form.ShowDialog(owner);
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)