Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git pull support for Visual Studio 2017 and 2019 #3

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions GitPull.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28412.107
# Visual Studio 15
VisualStudioVersion = 15.0.28307.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitPull", "src\GitPull.csproj", "{F03208D5-DA79-4B47-9A04-B802562AB242}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitPull", "src\GitPull\GitPull.csproj", "{F03208D5-DA79-4B47-9A04-B802562AB242}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0958FFB6-1CAA-4D59-973B-55CBE43745A3}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitPull.Services.15.0", "src\GitPull.Services.15.0\GitPull.Services.15.0.csproj", "{6CC39D34-677A-4474-AF19-E63CB343D2EE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitPull.Services", "src\GitPull.Services\GitPull.Services.csproj", "{BAFFF30C-FE61-4B1F-B5B6-D28520AC777D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitPull.Services.16.0", "src\GitPull.Services.16.0\GitPull.Services.16.0.csproj", "{5A441C17-A176-4DEF-A00E-DCC1662747EC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +27,18 @@ Global
{F03208D5-DA79-4B47-9A04-B802562AB242}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F03208D5-DA79-4B47-9A04-B802562AB242}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F03208D5-DA79-4B47-9A04-B802562AB242}.Release|Any CPU.Build.0 = Release|Any CPU
{6CC39D34-677A-4474-AF19-E63CB343D2EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CC39D34-677A-4474-AF19-E63CB343D2EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CC39D34-677A-4474-AF19-E63CB343D2EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CC39D34-677A-4474-AF19-E63CB343D2EE}.Release|Any CPU.Build.0 = Release|Any CPU
{BAFFF30C-FE61-4B1F-B5B6-D28520AC777D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAFFF30C-FE61-4B1F-B5B6-D28520AC777D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAFFF30C-FE61-4B1F-B5B6-D28520AC777D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAFFF30C-FE61-4B1F-B5B6-D28520AC777D}.Release|Any CPU.Build.0 = Release|Any CPU
{5A441C17-A176-4DEF-A00E-DCC1662747EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A441C17-A176-4DEF-A00E-DCC1662747EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A441C17-A176-4DEF-A00E-DCC1662747EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A441C17-A176-4DEF-A00E-DCC1662747EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ install:

before_build:
- ps: Vsix-IncrementVsixVersion | Vsix-UpdateBuildVersion
- ps: Vsix-TokenReplacement src\source.extension.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"'
- ps: Vsix-TokenReplacement src\GitPull\source.extension.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"'

build_script:
- nuget restore -Verbosity quiet
Expand Down
Binary file added lib/15.0/Microsoft.TeamFoundation.Common.dll
Binary file not shown.
Binary file added lib/15.0/Microsoft.TeamFoundation.Controls.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added lib/16.0/Microsoft.TeamFoundation.Common.dll
Binary file not shown.
Binary file added lib/16.0/Microsoft.TeamFoundation.Controls.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
140 changes: 0 additions & 140 deletions src/Commands/PullCommand.cs

This file was deleted.

39 changes: 39 additions & 0 deletions src/GitPull.Services.15.0/GitPull.Services.15.0.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<RootNamespace>GitPull.Services</RootNamespace>
<TeamExploerPath>..\..\lib\15.0</TeamExploerPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IgnoresAccessChecksToGenerator" Version="0.4.0" />
<PackageReference Include="Madskristensen.VisualStudio.SDK" Version="15.0.81-pre" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GitPull.Services\GitPull.Services.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.Git.Controls">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Git.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Git.CoreServices">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Git.CoreServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Git.Provider">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Git.Provider.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Controls">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Controls.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
</ItemGroup>

<PropertyGroup>
<InternalsAssemblyNames>Microsoft.TeamFoundation.Git.Controls;Microsoft.TeamFoundation.Git.CoreServices;Microsoft.TeamFoundation.Git.Provider;Microsoft.TeamFoundation.Controls</InternalsAssemblyNames>
</PropertyGroup>


</Project>
9 changes: 9 additions & 0 deletions src/GitPull.Services.15.0/TeamExplorerService15.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace GitPull.Services
{
public class TeamExplorerService15 : TeamExplorerServiceBase
{
public TeamExplorerService15(IServiceProvider serviceProvider) : base(serviceProvider) { }
}
}
59 changes: 59 additions & 0 deletions src/GitPull.Services.15.0/TeamExplorerServiceBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Threading.Tasks;
using Microsoft;
using Microsoft.TeamFoundation.Controls;
using Microsoft.TeamFoundation.Git.Controls.Commits;
using Microsoft.TeamFoundation.Git.CoreServices;
using Microsoft.TeamFoundation.Git.Provider;
using Microsoft.VisualStudio.TeamFoundation.Git.Extensibility;

namespace GitPull.Services
{
// This needs to be compiled against TeamFoundation assemblies for the target Visual Studio version
public abstract class TeamExplorerServiceBase : ITeamExplorerService
{
readonly IServiceProvider serviceProvider;

public TeamExplorerServiceBase(IServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider;
}

public async Task PullAsync(string repositoryPath)
{
Assumes.Present(repositoryPath);
var service = serviceProvider.GetService(typeof(SccService)) as SccService;
Assumes.Present(service);
var teamExplorer = service.GetSccService<ITeamExplorer>();
Assumes.NotNull(teamExplorer);
var page = await NavigateToPageAsync(teamExplorer, new Guid(TeamExplorerPageIds.GitCommits));
Assumes.NotNull(page);
var gitCommitsPageView = page.PageContent as GitCommitsPageView;
Assumes.NotNull(gitCommitsPageView);
var gitCommitsPageViewModel = gitCommitsPageView.ViewModel as GitCommitsPageViewModel;
Assumes.NotNull(gitCommitsPageViewModel);
await gitCommitsPageViewModel.PullAsync(repositoryPath);
}

static async Task<ITeamExplorerPage> NavigateToPageAsync(ITeamExplorer teamExplorer, Guid pageId)
{
// Page sometimes returns null so we need to wait for CurrentPage to change
var page = teamExplorer.NavigateToPage(pageId, null);
while (page?.GetId() != pageId)
{
await Task.Delay(1000);
page = teamExplorer.CurrentPage;
}

return page;
}

public string FindActiveRepositoryPath()
{
return
serviceProvider.GetService(typeof(IGitExt)) is IGitExt gitExt &&
gitExt.ActiveRepositories is var repos &&
repos.Count > 0 ? repos[0].RepositoryPath : null;
}
}
}
42 changes: 42 additions & 0 deletions src/GitPull.Services.16.0/GitPull.Services.16.0.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<RootNamespace>GitPull.Services</RootNamespace>
<TeamExploerPath>..\..\lib\16.0</TeamExploerPath>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\GitPull.Services.15.0\TeamExplorerServiceBase.cs" Link="TeamExplorerServiceBase.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="IgnoresAccessChecksToGenerator" Version="0.4.0" />
<PackageReference Include="Madskristensen.VisualStudio.SDK" Version="15.0.81-pre" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GitPull.Services\GitPull.Services.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.TeamFoundation.Git.Controls">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Git.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Git.CoreServices">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Git.CoreServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Git.Provider">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Git.Provider.dll</HintPath>
</Reference>
<Reference Include="Microsoft.TeamFoundation.Controls">
<HintPath>$(TeamExploerPath)\Microsoft.TeamFoundation.Controls.dll</HintPath>
</Reference>
</ItemGroup>

<PropertyGroup>
<InternalsAssemblyNames>Microsoft.TeamFoundation.Git.Controls;Microsoft.TeamFoundation.Git.CoreServices;Microsoft.TeamFoundation.Git.Provider;Microsoft.TeamFoundation.Controls</InternalsAssemblyNames>
</PropertyGroup>


</Project>
9 changes: 9 additions & 0 deletions src/GitPull.Services.16.0/TeamExplorerService16.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace GitPull.Services
{
public class TeamExplorerService16 : TeamExplorerServiceBase
{
public TeamExplorerService16(IServiceProvider serviceProvider) : base(serviceProvider) { }
}
}
11 changes: 11 additions & 0 deletions src/GitPull.Services/GitPull.Services.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Madskristensen.VisualStudio.SDK" Version="15.0.81-pre" />
</ItemGroup>

</Project>
Loading