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

Conversation

jcansdale
Copy link
Contributor

@jcansdale jcansdale commented Dec 27, 2018

The aim of this PR is to use Team Explorer to perform a git pull after Hub has synced all branches. This is complicated by Team Explorer not making this functionality easily available. 😉

What this PR does

  • Add support for Visual Studio 2017 and 2019
  • Target Visual Studio 2017 15.6 and above (FileAndForget was added in 15.6)
  • Sync all branches using Hub
  • Send output to existing Source Control - Git output pane
  • Send % output to status bar (Hub exposes this is standard Error)
  • Use Team Explorer - Synchronization page to pull the current branch
  • Uses IgnoresAccessChecksToGenerator to access internal Team Explorer classes (e.g. GitCommitsPageViewModel)

To do

  • Hub creates lots of noise when enumerating and downloading objects

E.g:

remote: Enumerating objects: 101, done.        
remote: Counting objects:   0% (1/101)           
remote: Counting objects:   1% (2/101)           
remote: Counting objects:   2% (3/101)           
remote: Counting objects:   3% (4/101)           
remote: Counting objects:   4% (5/101)           
remote: Counting objects:   5% (6/101)           
remote: Counting objects:   6% (7/101)           
remote: Counting objects:   7% (8/101)           
remote: Counting objects:   8% (9/101)           
remote: Counting objects:   9% (10/101)           
remote: Counting objects:  10% (11/101)   

Maybe this could be recognized and redirected to the status bar?

  • Lots of build warnings

E.g.

  GitPull.Services -> C:\projects\gitpull\src\GitPull.Services\bin\Release\net46\GitPull.Services.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3277: Found conflicts between different versions of "Microsoft.VisualStudio.Threading" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [C:\projects\gitpull\src\GitPull.Services.15.0\GitPull.Services.15.0.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3277: Found conflicts between different versions of "Newtonsoft.Json" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. 

https://ci.appveyor.com/project/madskristensen/gitpull/builds/21281211#L37

@madskristensen do you know if there is any way to fix these? ☝️

Fixes #2

Sorry, something went wrong.

Use GitCommitsPageViewModel on Team Explorer GitCommits page to pull.
This implementation uses IgnoresAccessChecksToGenerator so we can
access the required classes.
Don't infer the repository path from the solution.
Expose IHubService and ITeamExplorerService using
AyncPackage.AddService.
Extract command action to GitPullUIService.SyncAndPullAsync.
Export the IGitPullUIService service.
Add Assumes.NotNull checks to PullAsync .
Use TeamExplorerService15 for Visual Studio 2017 and
TeamExplorerService16 for 2019.
These assemblies aren't available on NuGet.
No more need to special case "fatal: Not a git repository".
No need to create our own.
Activate Output window when text is first output by SyncAndPullAsync.
Project moved into GitPull folder.
Hub exposes this using StandardError.
Add PackageReference for Madskristensen.VisualStudio.SDK 15.6 and
remove unnecessary references.
It looks like FileAndForget was added in Visual Studio SDK 15.6.
@jcansdale jcansdale changed the title [WIP] Add git pull support for Visual Studio 2017 and 2019 Add git pull support for Visual Studio 2017 and 2019 Dec 29, 2018
@@ -10,7 +10,7 @@
<Tags>git</Tags>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.6, 17.0)" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like 15.6 doesn't mean what I thought it meant. This version won't install on VS 2017 15.9. 😕

@madskristensen What should this version be if I want it to install on 15.6 or above?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madskristensen
Copy link
Owner

Let me know when I should merge this PR

@madskristensen
Copy link
Owner

Actually, let me just make you contributor on this

@tekkenxpert
Copy link

Hi all,
Is this extension compatible with VS2017? I'm getting the below error

Capture

@madskristensen
Copy link
Owner

@jcansdale is this ready for merge?

@jcansdale
Copy link
Contributor Author

Hi @madskristensen 👋

In hindsight I think this was too risky. It was accessing internal functionality IIRC. 😢

Alas, I don't spend much time inside VS these days. I'm going to close this PR as an experiment.

@jcansdale jcansdale closed this May 5, 2020
@madskristensen
Copy link
Owner

ok

@tekkenxpert
Copy link

Hi mads/jcansdale,

Is this supported in VS 2019, or are you dropping this completely?

@jcansdale
Copy link
Contributor Author

@tekkenxpert,

Is this supported in VS 2019, or are you dropping this completely?

It was using a trick to access an internal API, see the IgnoresAccessChecksToGenerator package here and here. This worked but was maybe a little too sketchy to be supportable. 😉

I know the Visual Studio team are doing a complete revamp of their Git support (see recent Preview versions of VS). If this is a feature you really want, this might not be a bad time to ask about it. I think there is similar functionality in VS Code which could help your case.

At the moment I'm a somewhat reluctant Mac user, so I don't get much time to hack on VS. 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for versions of Visual studio before 2019
3 participants