Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 7210bce

Browse files
Merge pull request #10 from GitTools/feature/issuetrackers
Added first support for issue trackers
2 parents 5cf4e7b + 914e704 commit 7210bce

39 files changed

+950
-17
lines changed
Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>GitTools.IssueTrackers</id>
5+
<version>[VERSION]</version>
6+
<title>GitTools.IssueTrackers</title>
7+
<authors>gittools</authors>
8+
<owners>gittools</owners>
9+
10+
<description>
11+
Issue Trackers core library for GitTools.
12+
</description>
13+
<summary>
14+
</summary>
15+
16+
<tags>git tools issue tracker</tags>
17+
18+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
19+
<copyright>Copyright GitTools team 2010 - 2015</copyright>
20+
21+
<language>en-US</language>
22+
<projectUrl>https://github.com/GitTools/GitTools.Core</projectUrl>
23+
<!--<licenseUrl>http://catel.codeplex.com/license</licenseUrl>-->
24+
<!--<iconUrl>http://www.catenalogic.com/catel.png</iconUrl>-->
25+
26+
<dependencies>
27+
<dependency id="GitTools.Core" version="[VERSION]" />
28+
29+
<!--<dependency id="GitTools.Core" version="[replaced]" />-->
30+
</dependencies>
31+
</metadata>
32+
</package>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
namespace GitTools.Tests
2+
{
3+
using NUnit.Framework;
4+
5+
[TestFixture]
6+
public class IAuthenticationContextExtensionsFacts
7+
{
8+
[TestCase("user", "password", null, false)]
9+
[TestCase(null, null, "token", false)]
10+
[TestCase(null, null, null, true)]
11+
public void TheIsEmptyMethod(string username, string password, string token, bool expectedValue)
12+
{
13+
var authenticationContext = new AuthenticationContext
14+
{
15+
Username = username,
16+
Password = password,
17+
Token = token
18+
};
19+
20+
Assert.AreEqual(expectedValue, authenticationContext.IsEmpty());
21+
}
22+
23+
[TestCase("user", "password", null, true)]
24+
[TestCase(null, null, "token", false)]
25+
[TestCase(null, null, null, false)]
26+
public void TheIsUsernameAndPasswordAuthenticationMethod(string username, string password, string token, bool expectedValue)
27+
{
28+
var authenticationContext = new AuthenticationContext
29+
{
30+
Username = username,
31+
Password = password,
32+
Token = token
33+
};
34+
35+
Assert.AreEqual(expectedValue, authenticationContext.IsUsernameAndPasswordAuthentication());
36+
}
37+
38+
[TestCase("user", "password", null, false)]
39+
[TestCase(null, null, "token", true)]
40+
[TestCase(null, null, null, false)]
41+
public void TheIsTokenAuthenticationMethod(string username, string password, string token, bool expectedValue)
42+
{
43+
var authenticationContext = new AuthenticationContext
44+
{
45+
Username = username,
46+
Password = password,
47+
Token = token
48+
};
49+
50+
Assert.AreEqual(expectedValue, authenticationContext.IsTokenAuthentication());
51+
}
52+
}
53+
}

src/GitTools.Core.Tests/GitTools.Core.Tests.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<NoWarn>1591;1998</NoWarn>
3737
</PropertyGroup>
3838
<ItemGroup>
39+
<Reference Include="Jira.SDK">
40+
<HintPath>..\..\lib\Jira.SDK.1.1.1.2\lib\net45\Jira.SDK.dll</HintPath>
41+
<Private>True</Private>
42+
</Reference>
3943
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
4044
<HintPath>..\..\lib\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
4145
<Private>True</Private>
@@ -59,6 +63,7 @@
5963
<Compile Include="ArgumentParserFacts.cs" />
6064
<Compile Include="ContextFacts.cs" />
6165
<Compile Include="Context\Context.cs" />
66+
<Compile Include="Context\Extensions\IAuthenticationContextExtensionsFacts.cs" />
6267
<Compile Include="Extensions\StringExtensionsFacts.cs" />
6368
<Compile Include="GlobalInitialization.cs" />
6469
<Compile Include="ModuleInitializer.cs" />
@@ -69,6 +74,10 @@
6974
<Project>{c11252f9-0eca-44dc-860b-e029c04fbd10}</Project>
7075
<Name>GitTools.Core</Name>
7176
</ProjectReference>
77+
<ProjectReference Include="..\GitTools.IssueTrackers\GitTools.IssueTrackers.csproj">
78+
<Project>{ac5f41ea-962e-491b-8557-a2a10dc757e4}</Project>
79+
<Name>GitTools.IssueTrackers</Name>
80+
</ProjectReference>
7281
</ItemGroup>
7382
<ItemGroup>
7483
<Content Include="FodyWeavers.xml" />
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Fody" version="1.29.0-beta01" targetFramework="net45" userInstalled="true" />
4-
<package id="ModuleInit.Fody" version="1.5.6.0" targetFramework="net45" developmentDependency="true" userInstalled="true" />
5-
<package id="NUnit" version="2.6.4" targetFramework="net45" userInstalled="true" />
6-
<package id="Shouldly" version="2.5.0" targetFramework="net45" userInstalled="true" />
3+
<package id="Fody" version="1.29.0-beta01" targetFramework="net45" />
4+
<package id="Jira.SDK" version="1.1.1.2" targetFramework="net45" />
5+
<package id="ModuleInit.Fody" version="1.5.6.0" targetFramework="net45" developmentDependency="true" />
6+
<package id="NUnit" version="2.6.4" targetFramework="net45" />
7+
<package id="Shouldly" version="2.5.0" targetFramework="net45" />
78
</packages>

src/GitTools.Core.sln

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.31101.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.22823.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Core", "GitTools.Core\GitTools.Core.csproj", "{C11252F9-0ECA-44DC-860B-E029C04FBD10}"
77
EndProject
@@ -26,6 +26,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{532E0393-2C1
2626
EndProject
2727
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Core.Tests", "GitTools.Core.Tests\GitTools.Core.Tests.csproj", "{0834BE9B-5CDE-4CAB-A683-C70A7D91450B}"
2828
EndProject
29+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core.IssueTrackers", "Core.IssueTrackers", "{5E7A6723-E488-4CFF-B838-B5ABA6B38479}"
30+
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.IssueTrackers", "GitTools.IssueTrackers\GitTools.IssueTrackers.csproj", "{AC5F41EA-962E-491B-8557-A2A10DC757E4}"
32+
EndProject
2933
Global
3034
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3135
Debug|Any CPU = Debug|Any CPU
@@ -40,6 +44,10 @@ Global
4044
{0834BE9B-5CDE-4CAB-A683-C70A7D91450B}.Debug|Any CPU.Build.0 = Debug|Any CPU
4145
{0834BE9B-5CDE-4CAB-A683-C70A7D91450B}.Release|Any CPU.ActiveCfg = Release|Any CPU
4246
{0834BE9B-5CDE-4CAB-A683-C70A7D91450B}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{AC5F41EA-962E-491B-8557-A2A10DC757E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48+
{AC5F41EA-962E-491B-8557-A2A10DC757E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
49+
{AC5F41EA-962E-491B-8557-A2A10DC757E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
50+
{AC5F41EA-962E-491B-8557-A2A10DC757E4}.Release|Any CPU.Build.0 = Release|Any CPU
4351
EndGlobalSection
4452
GlobalSection(SolutionProperties) = preSolution
4553
HideSolutionNode = FALSE
@@ -49,5 +57,7 @@ Global
4957
{1E56230A-4CDE-4142-A7F0-BE0625746DA0} = {17E77AE6-5E23-4898-BCAB-7AF62BB0DFBA}
5058
{377F4B45-0F5E-4F78-8A7B-27725DC79197} = {17E77AE6-5E23-4898-BCAB-7AF62BB0DFBA}
5159
{0834BE9B-5CDE-4CAB-A683-C70A7D91450B} = {377F4B45-0F5E-4F78-8A7B-27725DC79197}
60+
{5E7A6723-E488-4CFF-B838-B5ABA6B38479} = {17E77AE6-5E23-4898-BCAB-7AF62BB0DFBA}
61+
{AC5F41EA-962E-491B-8557-A2A10DC757E4} = {5E7A6723-E488-4CFF-B838-B5ABA6B38479}
5262
EndGlobalSection
5363
EndGlobal

src/GitTools.Core/App_Packages/LibLog.4.2/LibLog.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
#pragma warning disable 1591
4040

41+
#define LIBLOG_PUBLIC
42+
4143
// If you copied this file manually, you need to change all "YourRootNameSpace" so not to clash with other libraries
4244
// that use LibLog
4345
#if LIBLOG_PROVIDERS_ONLY
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace GitTools
2+
{
3+
using System.Security;
4+
5+
public class AuthenticationContext : Disposable, IAuthenticationContext
6+
{
7+
public AuthenticationContext()
8+
{
9+
}
10+
11+
public AuthenticationContext(string username, string password)
12+
{
13+
Username = username;
14+
Password = password;
15+
}
16+
17+
public AuthenticationContext(string token)
18+
{
19+
Token = token;
20+
}
21+
22+
public string Username { get; set; }
23+
public string Password { get; set; }
24+
public string Token { get; set; }
25+
26+
/// <summary>
27+
/// Disposes the managed resources.
28+
/// </summary>
29+
protected override void DisposeManaged()
30+
{
31+
base.DisposeManaged();
32+
33+
// TODO: dipose secure strings if needed
34+
}
35+
}
36+
}

src/GitTools.Core/Context/ContextBase.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace GitTools
22
{
3-
public abstract class ContextBase : IContext
3+
public abstract class ContextBase : Disposable, IContext
44
{
55
public ContextBase()
66
{
@@ -10,5 +10,16 @@ public ContextBase()
1010
public bool IsHelp { get; set; }
1111

1212
public IRepositoryContext Repository { get; set; }
13+
14+
protected override void DisposeManaged()
15+
{
16+
base.DisposeManaged();
17+
18+
var repository = Repository;
19+
if (repository != null)
20+
{
21+
repository.Dispose();
22+
}
23+
}
1324
}
1425
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
namespace GitTools
2+
{
3+
using Logging;
4+
5+
public static class IAuthenticationContextExtensions
6+
{
7+
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
8+
9+
public static bool IsEmpty(this IAuthenticationContext authenticationContext)
10+
{
11+
if (authenticationContext == null)
12+
{
13+
return true;
14+
}
15+
16+
if (IsUsernameAndPasswordAuthentication(authenticationContext))
17+
{
18+
return false;
19+
}
20+
21+
if (IsTokenAuthentication(authenticationContext))
22+
{
23+
return false;
24+
}
25+
26+
return true;
27+
}
28+
29+
public static bool IsUsernameAndPasswordAuthentication(this IAuthenticationContext authenticationContext)
30+
{
31+
if (authenticationContext == null)
32+
{
33+
return false;
34+
}
35+
36+
if (string.IsNullOrWhiteSpace(authenticationContext.Username))
37+
{
38+
return false;
39+
}
40+
41+
if (string.IsNullOrWhiteSpace(authenticationContext.Password))
42+
{
43+
return false;
44+
}
45+
46+
return true;
47+
}
48+
49+
public static bool IsTokenAuthentication(this IAuthenticationContext authenticationContext)
50+
{
51+
if (authenticationContext == null)
52+
{
53+
return false;
54+
}
55+
56+
if (string.IsNullOrWhiteSpace(authenticationContext.Token))
57+
{
58+
return false;
59+
}
60+
61+
return true;
62+
}
63+
}
64+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace GitTools
2+
{
3+
using Logging;
4+
5+
public static class IRepositoryContextExtensions
6+
{
7+
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
8+
9+
public static bool Validate(this IRepositoryContext context)
10+
{
11+
if (string.IsNullOrWhiteSpace(context.Url))
12+
{
13+
Log.Error("Repository.Url is required");
14+
return false;
15+
}
16+
17+
if (string.IsNullOrWhiteSpace(context.Branch))
18+
{
19+
Log.Error("Repository.Branch is required");
20+
return false;
21+
}
22+
23+
return true;
24+
}
25+
}
26+
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
namespace GitTools
22
{
3-
public interface IAuthenticationContext
3+
using System;
4+
using System.Security;
5+
6+
public interface IAuthenticationContext : IDisposable
47
{
58
string Username { get; set; }
69

710
string Password { get; set; }
11+
12+
string Token { get; set; }
813
}
914
}

src/GitTools.Core/Context/Interfaces/IContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace GitTools
22
{
3-
public interface IContext
3+
using System;
4+
5+
public interface IContext : IDisposable
46
{
57
bool IsHelp { get; set; }
68
IRepositoryContext Repository { get; set; }

src/GitTools.Core/Context/Interfaces/IRepositoryContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
namespace GitTools
22
{
3-
public interface IRepositoryContext : IAuthenticationContext
3+
using System;
4+
5+
public interface IRepositoryContext : IDisposable
46
{
7+
IAuthenticationContext Authentication { get; }
8+
59
string Directory { get; set; }
610

711
string Branch { get; set; }

0 commit comments

Comments
 (0)