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

Commit decd642

Browse files
committed
Split VS version-specific methods from general ones
1 parent 3bfc81e commit decd642

File tree

16 files changed

+118
-78
lines changed

16 files changed

+118
-78
lines changed

src/GitHub.App/Services/RepositoryCloneService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public class RepositoryCloneService : IRepositoryCloneService
2222

2323
readonly IOperatingSystem operatingSystem;
2424
readonly string defaultClonePath;
25-
readonly IVSServices vsservices;
25+
readonly IVSGitServices vsGitServices;
2626

2727
[ImportingConstructor]
28-
public RepositoryCloneService(IOperatingSystem operatingSystem, IVSServices vsservices)
28+
public RepositoryCloneService(IOperatingSystem operatingSystem, IVSGitServices vsGitServices)
2929
{
3030
this.operatingSystem = operatingSystem;
31-
this.vsservices = vsservices;
31+
this.vsGitServices = vsGitServices;
3232

3333
defaultClonePath = GetLocalClonePathFromGitProvider(operatingSystem.Environment.GetUserRepositoriesPath());
3434
}
@@ -48,7 +48,7 @@ public IObservable<Unit> CloneRepository(string cloneUrl, string repositoryName,
4848
try
4949
{
5050
// this will throw if it can't find it
51-
vsservices.Clone(cloneUrl, path, true);
51+
vsGitServices.Clone(cloneUrl, path, true);
5252
}
5353
catch (Exception ex)
5454
{
@@ -62,7 +62,7 @@ public IObservable<Unit> CloneRepository(string cloneUrl, string repositoryName,
6262

6363
string GetLocalClonePathFromGitProvider(string fallbackPath)
6464
{
65-
var ret = vsservices.GetLocalClonePathFromGitProvider();
65+
var ret = vsGitServices.GetLocalClonePathFromGitProvider();
6666
return !string.IsNullOrEmpty(ret)
6767
? operatingSystem.Environment.ExpandEnvironmentVariables(ret)
6868
: fallbackPath;

src/GitHub.App/Services/RepositoryPublishService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public class RepositoryPublishService : IRepositoryPublishService
1616
readonly IRepository activeRepository;
1717

1818
[ImportingConstructor]
19-
public RepositoryPublishService(IGitClient gitClient, IVSServices services)
19+
public RepositoryPublishService(IGitClient gitClient, IVSGitServices vsGitServices)
2020
{
2121
this.gitClient = gitClient;
22-
this.activeRepository = services.GetActiveRepo();
22+
this.activeRepository = vsGitServices.GetActiveRepo();
2323
}
2424

2525
public string LocalRepositoryName

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
<Compile Include="Services\ITeamExplorerServiceHolder.cs" />
131131
<Compile Include="Services\INotificationService.cs" />
132132
<Compile Include="Services\IUsageTracker.cs" />
133+
<Compile Include="Services\IVSGitServices.cs" />
133134
<Compile Include="Services\IVSServices.cs" />
134135
<Compile Include="Services\Logger.cs" />
135136
<Compile Include="Services\Services.cs" />
@@ -145,6 +146,7 @@
145146
<Compile Include="Authentication\AuthenticationResultExtensions.cs" />
146147
<Compile Include="Extensions\ServiceProviderExtensions.cs" />
147148
<Compile Include="Services\UsageTracker.cs" />
149+
<Compile Include="Services\VSServices.cs" />
148150
<Compile Include="Settings\generated\IPackageSettings.cs">
149151
<AutoGen>True</AutoGen>
150152
<DesignTime>True</DesignTime>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
using GitHub.Models;
3+
4+
namespace GitHub.Services
5+
{
6+
public interface IVSGitServices
7+
{
8+
string GetLocalClonePathFromGitProvider();
9+
void Clone(string cloneUrl, string clonePath, bool recurseSubmodules);
10+
string GetActiveRepoPath();
11+
LibGit2Sharp.IRepository GetActiveRepo();
12+
IEnumerable<ISimpleRepositoryModel> GetKnownRepositories();
13+
string SetDefaultProjectPath(string path);
14+
}
15+
}

src/GitHub.Exports/Services/IVSServices.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ namespace GitHub.Services
55
{
66
public interface IVSServices
77
{
8-
string GetLocalClonePathFromGitProvider();
9-
void Clone(string cloneUrl, string clonePath, bool recurseSubmodules);
10-
string GetActiveRepoPath();
11-
LibGit2Sharp.IRepository GetActiveRepo();
12-
IEnumerable<ISimpleRepositoryModel> GetKnownRepositories();
13-
string SetDefaultProjectPath(string path);
14-
158
void ActivityLogMessage(string message);
169
void ActivityLogWarning(string message);
1710
void ActivityLogError(string message);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.ComponentModel.Composition;
5+
using System.Globalization;
6+
using GitHub.VisualStudio;
7+
using Microsoft.VisualStudio;
8+
using Microsoft.VisualStudio.Shell.Interop;
9+
10+
namespace GitHub.Services
11+
{
12+
[Export(typeof(IVSServices))]
13+
[PartCreationPolicy(CreationPolicy.Shared)]
14+
public class VSServices : IVSServices
15+
{
16+
readonly IUIProvider serviceProvider;
17+
18+
[ImportingConstructor]
19+
public VSServices(IUIProvider serviceProvider)
20+
{
21+
this.serviceProvider = serviceProvider;
22+
}
23+
24+
25+
public void ActivityLogMessage(string message)
26+
{
27+
var log = serviceProvider.GetActivityLog();
28+
if (log != null)
29+
{
30+
if (!ErrorHandler.Succeeded(log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION,
31+
Info.ApplicationInfo.ApplicationSafeName, message)))
32+
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not log message to activity log: {0}", message));
33+
}
34+
}
35+
36+
public void ActivityLogError(string message)
37+
{
38+
var log = serviceProvider.GetActivityLog();
39+
if (log != null)
40+
{
41+
42+
if (!ErrorHandler.Succeeded(log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
43+
Info.ApplicationInfo.ApplicationSafeName, message)))
44+
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not log error to activity log: {0}", message));
45+
}
46+
}
47+
48+
public void ActivityLogWarning(string message)
49+
{
50+
var log = serviceProvider.GetActivityLog();
51+
if (log != null)
52+
{
53+
if (!ErrorHandler.Succeeded(log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_WARNING,
54+
Info.ApplicationInfo.ApplicationSafeName, message)))
55+
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not log warning to activity log: {0}", message));
56+
}
57+
}
58+
}
59+
}

src/GitHub.TeamFoundation.14/Connect/GitHubConnectSection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ void ShowNotification(ISimpleRepositoryModel newrepo, string msg)
277277
}
278278
else if (prefix == "c:")
279279
{
280-
var vsservices = ServiceProvider.GetExportedValue<IVSServices>();
281-
vsservices.SetDefaultProjectPath(newrepo.LocalPath);
280+
var vsGitServices = ServiceProvider.GetExportedValue<IVSGitServices>();
281+
vsGitServices.SetDefaultProjectPath(newrepo.LocalPath);
282282
if (ErrorHandler.Succeeded(ServiceProvider.GetSolution().CreateNewProjectViaDlg(null, null, 0)))
283283
ServiceProvider.TryGetService<ITeamExplorer>()?.NavigateToPage(new Guid(TeamExplorerPageIds.Home), null);
284284
}

src/GitHub.TeamFoundation.14/GitHub.TeamFoundation.14.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
</ItemGroup>
108108
<ItemGroup>
109109
<Compile Include="RegistryHelper.cs" />
110-
<Compile Include="Services\VSServices.cs" />
110+
<Compile Include="Services\VSGitServices.cs" />
111111
<Compile Include="Settings.cs" />
112112
<Compile Include="Base\EnsureLoggedInSection.cs" />
113113
<Compile Include="Base\TeamExplorerInvitationBase.cs" />

src/GitHub.TeamFoundation.14/Services/VSServices.cs renamed to src/GitHub.TeamFoundation.14/Services/VSGitServices.cs

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
using GitHub.VisualStudio;
1010
using Microsoft.VisualStudio;
1111
using Microsoft.VisualStudio.Shell.Interop;
12-
using Microsoft.Win32;
13-
using System.Diagnostics;
1412
using GitHub.TeamFoundation;
1513
using Microsoft.TeamFoundation.Git.Controls.Extensibility;
1614
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;
1715

1816
namespace GitHub.Services
1917
{
20-
[Export(typeof(IVSServices))]
18+
[Export(typeof(IVSGitServices))]
2119
[PartCreationPolicy(CreationPolicy.Shared)]
22-
public class VSServices : IVSServices
20+
public class VSGitServices : IVSGitServices
2321
{
2422
readonly IUIProvider serviceProvider;
2523

@@ -32,7 +30,7 @@ public class VSServices : IVSServices
3230
IGitExt gitExtService;
3331

3432
[ImportingConstructor]
35-
public VSServices(IUIProvider serviceProvider)
33+
public VSGitServices(IUIProvider serviceProvider)
3634
{
3735
this.serviceProvider = serviceProvider;
3836
}
@@ -104,39 +102,5 @@ public string SetDefaultProjectPath(string path)
104102
{
105103
return RegistryHelper.SetDefaultProjectPath(path);
106104
}
107-
108-
public void ActivityLogMessage(string message)
109-
{
110-
var log = serviceProvider.GetActivityLog();
111-
if (log != null)
112-
{
113-
if (!ErrorHandler.Succeeded(log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION,
114-
Info.ApplicationInfo.ApplicationSafeName, message)))
115-
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not log message to activity log: {0}", message));
116-
}
117-
}
118-
119-
public void ActivityLogError(string message)
120-
{
121-
var log = serviceProvider.GetActivityLog();
122-
if (log != null)
123-
{
124-
125-
if (!ErrorHandler.Succeeded(log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_ERROR,
126-
Info.ApplicationInfo.ApplicationSafeName, message)))
127-
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not log error to activity log: {0}", message));
128-
}
129-
}
130-
131-
public void ActivityLogWarning(string message)
132-
{
133-
var log = serviceProvider.GetActivityLog();
134-
if (log != null)
135-
{
136-
if (!ErrorHandler.Succeeded(log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_WARNING,
137-
Info.ApplicationInfo.ApplicationSafeName, message)))
138-
Console.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not log warning to activity log: {0}", message));
139-
}
140-
}
141105
}
142106
}

src/GitHub.TeamFoundation.15/GitHub.TeamFoundation.15.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@
163163
<Compile Include="..\GitHub.TeamFoundation.14\Services\TeamExplorerServices.cs">
164164
<Link>Services\TeamExplorerServices.cs</Link>
165165
</Compile>
166-
<Compile Include="..\GitHub.TeamFoundation.14\Services\VSServices.cs">
167-
<Link>Services\VSServices.cs</Link>
166+
<Compile Include="..\GitHub.TeamFoundation.14\Services\VSGitServices.cs">
167+
<Link>Services\VSGitServices.cs</Link>
168168
</Compile>
169169
<Compile Include="RegistryHelper.cs" />
170170
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">

0 commit comments

Comments
 (0)