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

Commit 8841522

Browse files
authored
Merge branch 'master' into refactor/pr-sessions
2 parents 14e2ef7 + 7825fc2 commit 8841522

File tree

18 files changed

+117
-348
lines changed

18 files changed

+117
-348
lines changed
34.7 KB
Loading
124 KB
Loading

docs/contributing/reviewing-a-pull-request-in-visual-studio.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,26 @@ If the pull request is from a fork then a remote will be added to the forked rep
2626

2727
> Note that you cannot check out a pull request branch when your working directory has uncommitted changes. First commit or stash your changes and then refresh the Pull Request view.
2828
29-
## Comparing files
29+
## Viewing Changes
3030

31-
To compare the contents of a file in the pull request with its content on the target branch, double click a file in the **Changed Files** tree. This will open the Visual Studio diff viewer. If the pull request has been checked out, the right hand pane will be editable.
31+
To view the changes in the pull request for a file, double click a file in the **Changed Files** tree. This will open the Visual Studio diff viewer.
3232

3333
![Diff of two files in the Visual Studio diff viewer](images/pr-diff-files.png)
3434

35-
If the pull request is checked out, right clicking on a file on the **Changed Files** tree and selecting **Open File** will open the file for editing in Visual Studio.
35+
You can also right-click on a file in the changed files tree to get more options:
36+
37+
- **View Changes**: This is the default option that is also triggered when the file is double-clicked. It shows the changes to the file that are introduced by the pull request.
38+
- **View File**: This opens a read-only editor showing the contents of the file in the pull request.
39+
- **View Changes in Solution**: This menu item is only available when the pull request branch is checked out. It shows the changes in the pull request, but the right hand side of the diff is the file in the working directory. This view allows you to use Visual Studio navigation commands such as **Go to Definition (F12)**.
40+
- **Open File in Solution**: This menu item opens the working directory file in an editor.
41+
42+
## Leaving Comments
43+
44+
You can add comments to a pull request directly from Visual Studio. When a file is [open in the diff viewer](#viewing-changes) you can click the **Add Comment** icon in the margin to add a comment on a line.
45+
46+
![Hover over margin to see add comment icon](images/hover-to-add-comment.png)
47+
48+
Then click the icon on the desired line and leave a comment.
49+
![Add a comment](images/add-comment.png)
50+
51+
Existing comments left by you or other reviewers will also show up in this margin. Click the icon to open an inline conversation view from which you can review and reply to comments:

documentation/manifest.md

Lines changed: 0 additions & 266 deletions
This file was deleted.

install.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
@set path=%cd%\tools\VsixUtil;%path%
44

5-
vsixutil /install "%cd%\build\%Configuration%\GitHub.VisualStudio.vsix" /s Enterprise;Professional;Community
5+
vsixutil /install "%cd%\build\%Configuration%\GitHub.VisualStudio.vsix"
66
@echo Installed %Configuration% build of GitHub for Visual Studio

src/GitHub.App/SampleData/PullRequestListViewModelDesigner.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public PullRequestListViewModelDesigner()
3434
Assignee = new AccountDesigner { Login = "haacked", IsUser = true },
3535
});
3636
prs.Add(new PullRequestModel(409, "Fix publish button style and a really, really long name for this thing... OMG look how long this name is yusssss",
37-
new AccountDesigner { Login = "shana", IsUser = true },
37+
new AccountDesigner { Login = "shana", IsUser = true },
3838
DateTimeOffset.Now - TimeSpan.FromHours(5))
3939
{
4040
CommentCount = 27,
@@ -76,5 +76,6 @@ public PullRequestListViewModelDesigner()
7676

7777
public ReactiveCommand<object> OpenPullRequest { get; }
7878
public ReactiveCommand<object> CreatePullRequest { get; }
79+
public ReactiveCommand<object> OpenPullRequestOnGitHub { get; }
7980
}
8081
}

src/GitHub.App/Services/GitClient.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,32 +380,34 @@ public Task<bool> IsModified(IRepository repository, string path, byte[] content
380380
}
381381

382382
public async Task<string> GetPullRequestMergeBase(IRepository repo,
383-
UriString baseCloneUrl, UriString headCloneUrl, string baseSha, string headSha, string baseRef, string headRef)
383+
UriString targetCloneUrl, string baseSha, string headSha, string baseRef, int pullNumber)
384384
{
385385
Guard.ArgumentNotNull(repo, nameof(repo));
386-
Guard.ArgumentNotNull(baseCloneUrl, nameof(baseCloneUrl));
387-
Guard.ArgumentNotNull(headCloneUrl, nameof(headCloneUrl));
386+
Guard.ArgumentNotNull(targetCloneUrl, nameof(targetCloneUrl));
388387
Guard.ArgumentNotEmptyString(baseRef, nameof(baseRef));
389388

390-
var baseCommit = repo.Lookup<Commit>(baseSha);
391-
if (baseCommit == null)
389+
var headCommit = repo.Lookup<Commit>(headSha);
390+
if (headCommit == null)
392391
{
393-
await Fetch(repo, baseCloneUrl, baseRef);
394-
baseCommit = repo.Lookup<Commit>(baseSha);
395-
if (baseCommit == null)
392+
// The PR base branch might no longer exist, so we fetch using `refs/pull/<PR>/head` first.
393+
// This will often fetch the base commits, even when the base branch no longer exists.
394+
var headRef = $"refs/pull/{pullNumber}/head";
395+
await Fetch(repo, targetCloneUrl, headRef);
396+
headCommit = repo.Lookup<Commit>(headSha);
397+
if (headCommit == null)
396398
{
397-
throw new NotFoundException($"Couldn't find {baseSha} after fetching from {baseCloneUrl}:{baseRef}.");
399+
throw new NotFoundException($"Couldn't find {headSha} after fetching from {targetCloneUrl}:{headRef}.");
398400
}
399401
}
400402

401-
var headCommit = repo.Lookup<Commit>(headSha);
402-
if (headCommit == null)
403+
var baseCommit = repo.Lookup<Commit>(baseSha);
404+
if (baseCommit == null)
403405
{
404-
await Fetch(repo, headCloneUrl, headRef);
405-
headCommit = repo.Lookup<Commit>(headSha);
406-
if (headCommit == null)
406+
await Fetch(repo, targetCloneUrl, baseRef);
407+
baseCommit = repo.Lookup<Commit>(baseSha);
408+
if (baseCommit == null)
407409
{
408-
throw new NotFoundException($"Couldn't find {headSha} after fetching from {headCloneUrl}:{headRef}.");
410+
throw new NotFoundException($"Couldn't find {baseSha} after fetching from {targetCloneUrl}:{baseRef}.");
409411
}
410412
}
411413

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,10 @@ public IObservable<string> ExtractFile(
313313
sha = await gitClient.GetPullRequestMergeBase(
314314
repo,
315315
pullRequest.Base.RepositoryCloneUrl,
316-
pullRequest.Head.RepositoryCloneUrl,
317316
pullRequest.Base.Sha,
318317
pullRequest.Head.Sha,
319318
pullRequest.Base.Ref,
320-
pullRequest.Head.Ref);
319+
pullRequest.Number);
321320
}
322321
catch (NotFoundException ex)
323322
{

src/GitHub.App/ViewModels/PullRequestListViewModel.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
44
using System.ComponentModel.Composition;
5-
using System.Diagnostics;
65
using System.Linq;
76
using System.Reactive.Linq;
87
using System.Reactive.Subjects;
@@ -32,6 +31,7 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
3231
readonly TrackingCollection<IAccount> trackingAuthors;
3332
readonly TrackingCollection<IAccount> trackingAssignees;
3433
readonly IPackageSettings settings;
34+
readonly IVisualStudioBrowser visualStudioBrowser;
3535
readonly PullRequestListUIState listSettings;
3636
readonly bool constructing;
3737
IRemoteRepositoryModel remoteRepository;
@@ -40,8 +40,9 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
4040
PullRequestListViewModel(
4141
IConnectionRepositoryHostMap connectionRepositoryHostMap,
4242
ITeamExplorerServiceHolder teservice,
43-
IPackageSettings settings)
44-
: this(connectionRepositoryHostMap.CurrentRepositoryHost, teservice.ActiveRepo, settings)
43+
IPackageSettings settings,
44+
IVisualStudioBrowser visualStudioBrowser)
45+
: this(connectionRepositoryHostMap.CurrentRepositoryHost, teservice.ActiveRepo, settings, visualStudioBrowser)
4546
{
4647
Guard.ArgumentNotNull(connectionRepositoryHostMap, nameof(connectionRepositoryHostMap));
4748
Guard.ArgumentNotNull(teservice, nameof(teservice));
@@ -51,16 +52,19 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
5152
public PullRequestListViewModel(
5253
IRepositoryHost repositoryHost,
5354
ILocalRepositoryModel repository,
54-
IPackageSettings settings)
55+
IPackageSettings settings,
56+
IVisualStudioBrowser visualStudioBrowser)
5557
{
5658
Guard.ArgumentNotNull(repositoryHost, nameof(repositoryHost));
5759
Guard.ArgumentNotNull(repository, nameof(repository));
5860
Guard.ArgumentNotNull(settings, nameof(settings));
61+
Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));
5962

6063
constructing = true;
6164
this.repositoryHost = repositoryHost;
6265
this.localRepository = repository;
6366
this.settings = settings;
67+
this.visualStudioBrowser = visualStudioBrowser;
6468

6569
Title = Resources.PullRequestsNavigationItemText;
6670

@@ -108,6 +112,9 @@ public PullRequestListViewModel(
108112
CreatePullRequest = ReactiveCommand.Create();
109113
CreatePullRequest.Subscribe(_ => DoCreatePullRequest());
110114

115+
OpenPullRequestOnGitHub = ReactiveCommand.Create();
116+
OpenPullRequestOnGitHub.Subscribe(x => DoOpenPullRequestOnGitHub((int)x));
117+
111118
constructing = false;
112119
}
113120

@@ -269,6 +276,8 @@ public IAccount EmptyUser
269276
public ReactiveCommand<object> OpenPullRequest { get; }
270277
public ReactiveCommand<object> CreatePullRequest { get; }
271278

279+
public ReactiveCommand<object> OpenPullRequestOnGitHub { get; }
280+
272281
bool disposed;
273282
protected void Dispose(bool disposing)
274283
{
@@ -334,5 +343,12 @@ void DoCreatePullRequest()
334343
var d = new ViewWithData(UIControllerFlow.PullRequestCreation);
335344
navigate.OnNext(d);
336345
}
346+
347+
void DoOpenPullRequestOnGitHub(int pullRequest)
348+
{
349+
var repoUrl = SelectedRepository.CloneUrl.ToRepositoryUrl();
350+
var url = repoUrl.Append("pull/" + pullRequest);
351+
visualStudioBrowser.OpenUrl(url);
352+
}
337353
}
338354
}

src/GitHub.Exports.Reactive/Services/IGitClient.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ public interface IGitClient
188188
/// Find the merge base SHA between two commits.
189189
/// </summary>
190190
/// <param name="repository">The repository.</param>
191-
/// <param name="baseCloneUrl">The clone url of the PR base.</param>
192-
/// <param name="headCloneUrl">The clone url of the PR head.</param>
191+
/// <param name="targetCloneUrl">The clone url of the PR target repo.</param>
193192
/// <param name="baseSha">The PR base SHA.</param>
194193
/// <param name="headSha">The PR head SHA.</param>
195194
/// <param name="baseRef">The PR base ref (e.g. 'master').</param>
@@ -198,7 +197,7 @@ public interface IGitClient
198197
/// The merge base SHA or null.
199198
/// </returns>
200199
/// <exception cref="LibGit2Sharp.NotFoundException">Thrown when the merge base can't be found.</exception>
201-
Task<string> GetPullRequestMergeBase(IRepository repo, UriString baseCloneUrl, UriString headCloneUrl, string baseSha, string headSha, string baseRef, string headRef);
200+
Task<string> GetPullRequestMergeBase(IRepository repo, UriString targetCloneUrl, string baseSha, string headSha, string baseRef, int pullNumber);
202201

203202
/// Checks whether the current head is pushed to its remote tracking branch.
204203
/// </summary>

0 commit comments

Comments
 (0)