Skip to content

Add proof of concept, GitHub for Visual Studio integration#1

Open
jcansdale wants to merge 2 commits intolaurentkempe:masterfrom
jcansdale:GitHub-integration-hack
Open

Add proof of concept, GitHub for Visual Studio integration#1
jcansdale wants to merge 2 commits intolaurentkempe:masterfrom
jcansdale:GitHub-integration-hack

Conversation

@jcansdale
Copy link
Copy Markdown

@jcansdale jcansdale commented Feb 9, 2017

Hi Laurent,

I love the work you've done on GitDiffMargin. When I was looking at that, I noticed you'd also started the PReview project. 😄

This PR is a very simple proof of concept hack that lets PReview know which PR has been checked out using the PR functionality in GitHub for Visual Studio. All it does is expose the diff URL via some AppDomain data:

var diffUrl = (string)AppDomain.CurrentDomain.GetData("PReview.diff.url");

I also needed to update one of the NuGet packages to build/run with VS2015 R3.

To make it work you will need to use a similarly hacked branch of GitHubVS:
https://github.com/jcansdale/VisualStudio/tree/PReview-integration-hack

Try try it, do the following:

  1. Install these pre-built VSIX files: PReviewGitHub.zip
  2. Open the PReview.sln from this repo.
  3. On the Team Explorer window, select Pull Requests.
    image
  4. On the GitHub tool window, sellect this PR:
    image
  5. Checkout the PR:
    image
  6. Click on the Pull Request Filter option in Solution Explorer:
    image
  7. Woohoo! Super basic integration with the GitHub extension for Visual Studio! 😉

Note, this won't currently work with a private repo,

I'd be interested to know what information you would like from the PReview end?

I'm guessing knowing the PR target branch would be more useful? You could then generate the patch/diff file without needing to know the .diff URL (I'm assuming).

At the moment some branches are tagged with the PR # the .git\config file like this:

[branch "pr/734-pull-request-sorting"]
	remote = StanleyGoldman
	ghfvs-pr = 734

Maybe the target branch could also be added there? That way GitHubVS wouldn't even need to be running for PReview to find the PR details. Something like this:

[branch "pr/734-pull-request-sorting"]
	remote = StanleyGoldman
	ghfvs-pr = 734
	ghfvs-pr-target-branch = target-branch-for-PR

I'd be interested to hear your thoughts. 😄

Cheers,
Jamie.

Find the current PR diff URL using:
`(string)AppDomain.CurrentDomain.GetData("PReview.diff.url")`
This is just a proof of concept!
Bump Microsoft.VSSDK.BuildTools to version 14.3.25420.
@jcansdale
Copy link
Copy Markdown
Author

Updated original description with some screen-grabs.

@laurentkempe
Copy link
Copy Markdown
Owner

Hi Jamie,

I love the work you've done on GitDiffMargin. When I was looking at that, I noticed you'd also started the PReview project.

Nice to read that you love GitDiffMargin! PReview was a quick one evening hack to improve the efficiency of my team in our reviewing experience with git.

Nevertheless, I am happy to see that it got some interest, so thanks for the PR. I like the idea to have an integration with GitHub extension for Visual Studio, this can definitely improve the situation.

I'd be interested to know what information you would like from the PReview end?

For your current PR #1 I would need to get the same as what we get with this https://patch-diff.githubusercontent.com/raw/laurentkempe/PReview/pull/1.diff
So a patch file representing the changes of a merge into laurentkempe:master from jcansdale:GitHub-integration-hack

I'm guessing knowing the PR target branch would be more useful? You could then generate the patch/diff file without needing to know the .diff URL (I'm assuming).

Absolutely

Maybe the target branch could also be added there? That way GitHubVS wouldn't even need to be running for PReview to find the PR details. Something like this:

[branch "pr/734-pull-request-sorting"]
remote = StanleyGoldman
ghfvs-pr = 734
ghfvs-pr-target-branch = target-branch-for-PR

I guess that would be definitely an idea!

Cheers
Laurent

@jcansdale
Copy link
Copy Markdown
Author

jcansdale commented Feb 9, 2017

For your current PR #1 I would need to get the same as what we get with...

WebClient.OpenRead seems to happily handle the redirect from https://github.com/laurentkempe/PReview/pull/1.diff to there (though it will fail if the repro is private).

See:
https://github.com/jcansdale/PReview/blob/88a68cc5bb25d59cd67831f164552b08b127997c/PReview/Git/DiffParser.cs#L70

I'm curious to know how much difference there is between what PReview does and GitDiffMargin?

Could GitDiffMargin have an option to toggle between showing the diff to the staging area and the diff to master (or some other target branch)? Would this be similar to what PReview currently does?

@laurentkempe
Copy link
Copy Markdown
Owner

WebClient.OpenRead seems to happily handle the redirect from https://github.com/laurentkempe/PReview/pull/1.diff to there (though it will fail if the repro is private).

In fact the tricky part is not to get the data from the web, it is more to have a user friendly way so that the user can tell us which PR he wants to review, for that Github for Visual Studio is great!

I'm curious to know how much difference there is between what PReview does and GitDiffMargin?

Very few, in fact! This is why I could do it in one evening 😄 The tricky part was the Pull Request Filter button in VS which didn't had documentation or sample

Could GitDiffMargin have an option to toggle between showing the diff to the staging area and the diff to master (or some other target branch)? Would this be similar to what PReview currently does?

I think it was the same idea of @sharwell here laurentkempe/GitDiffMargin#68
Yes it would be quite similar

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.

2 participants