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

Commit d6a1e42

Browse files
authored
Merge branch 'master' into refactor/usage-tracker
2 parents 4210dfb + 7a64b1f commit d6a1e42

20 files changed

+416
-84
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Most of the extension UI lives in the Team Explorer pane, which is available fro
2121

2222
Official builds of this extension are available at [the official website](https://visualstudio.github.com).
2323

24+
25+
[![Build status](https://ci.appveyor.com/api/projects/status/dl8is5iqwt9qf3t7/branch/master?svg=true)](https://ci.appveyor.com/project/github-windows/visualstudio/branch/master)
26+
2427
[![Join the chat at freenode:github-vs](https://img.shields.io/badge/irc-freenode:%20%23github--vs-blue.svg)](http://webchat.freenode.net/?channels=%23github-vs) [![Join the chat at https://gitter.im/github/VisualStudio](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github/VisualStudio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2528

2629
## Documentation

install.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Configuration=%1
2-
@set path=%cd%\tools\VsixUtil;%path%
1+
@set Configuration=%1
2+
@if "%Configuration%" == "" echo Please specify Debug or Release
33
tools\VsixUtil\vsixutil /install "build\%Configuration%\GitHub.VisualStudio.vsix"
44
@echo Installed %Configuration% build of GitHub for Visual Studio

src/GitHub.App/Models/PullRequestDetailArgument.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using GitHub.ViewModels;
3+
using GitHub.Primitives;
34

45
namespace GitHub.Models
56
{
@@ -9,9 +10,9 @@ namespace GitHub.Models
910
public class PullRequestDetailArgument
1011
{
1112
/// <summary>
12-
/// Gets or sets the repository containing the pull request.
13+
/// Gets or sets the owner of the repository containing the pull request.
1314
/// </summary>
14-
public IRemoteRepositoryModel Repository { get; set; }
15+
public string RepositoryOwner { get; set; }
1516

1617
/// <summary>
1718
/// Gets or sets the number of the pull request.

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public PullRequestDetailViewModelDesigner()
3636
{
3737
var repoPath = @"C:\Repo";
3838

39-
Model = new PullRequestModel(419,
39+
Model = new PullRequestModel(419,
4040
"Error handling/bubbling from viewmodels to views to viewhosts",
4141
new AccountDesigner { Login = "shana", IsUser = true },
4242
DateTime.Now.Subtract(TimeSpan.FromDays(3)))
@@ -75,7 +75,7 @@ public PullRequestDetailViewModelDesigner()
7575
public IPullRequestModel Model { get; }
7676
public IPullRequestSession Session { get; }
7777
public ILocalRepositoryModel LocalRepository { get; }
78-
public IRemoteRepositoryModel RemoteRepository { get; }
78+
public string RemoteRepositoryOwner { get; }
7979
public string SourceBranchDisplayName { get; set; }
8080
public string TargetBranchDisplayName { get; set; }
8181
public int CommentCount { get; set; }

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,27 @@ public IObservable<IReadOnlyList<CommitMessage>> GetMessagesForUniqueCommits(
102102

103103
public IObservable<bool> IsWorkingDirectoryClean(ILocalRepositoryModel repository)
104104
{
105-
var repo = gitService.GetRepository(repository.LocalPath);
106-
return Observable.Return(!repo.RetrieveStatus().IsDirty);
105+
// The `using` appears to resolve this issue:
106+
// https://github.com/github/VisualStudio/issues/1306
107+
using (var repo = gitService.GetRepository(repository.LocalPath))
108+
{
109+
var isClean = !IsFilthy(repo.RetrieveStatus());
110+
return Observable.Return(isClean);
111+
}
112+
}
113+
114+
static bool IsFilthy(RepositoryStatus status)
115+
{
116+
if (status.IsDirty)
117+
{
118+
// This is similar to IsDirty, but also allows NewInWorkdir files
119+
return status.Any(entry =>
120+
entry.State != FileStatus.Ignored &&
121+
entry.State != FileStatus.Unaltered &&
122+
entry.State != FileStatus.NewInWorkdir);
123+
}
124+
125+
return false;
107126
}
108127

109128
public IObservable<Unit> Pull(ILocalRepositoryModel repository)

src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ private set
148148
public ILocalRepositoryModel LocalRepository { get; }
149149

150150
/// <summary>
151-
/// Gets the remote repository that contains the pull request.
151+
/// Gets the owner of the remote repository that contains the pull request.
152152
/// </summary>
153153
/// <remarks>
154154
/// The remote repository may be different from the local repository if the local
155155
/// repository is a fork and the user is viewing pull requests from the parent repository.
156156
/// </remarks>
157-
public IRemoteRepositoryModel RemoteRepository { get; private set; }
157+
public string RemoteRepositoryOwner { get; private set; }
158158

159159
/// <summary>
160160
/// Gets the session for the pull request.
@@ -326,13 +326,13 @@ public IReadOnlyList<IPullRequestChangeNode> ChangedFilesTree
326326
public override void Initialize(ViewWithData data)
327327
{
328328
int number;
329-
var repo = RemoteRepository;
329+
var repoOwner = RemoteRepositoryOwner;
330330

331331
if (data != null)
332332
{
333333
var arg = (PullRequestDetailArgument)data.Data;
334334
number = arg.Number;
335-
repo = arg.Repository;
335+
repoOwner = arg.RepositoryOwner;
336336
}
337337
else
338338
{
@@ -349,7 +349,7 @@ public override void Initialize(ViewWithData data)
349349
}
350350

351351
ErrorMessage = OperationError = null;
352-
modelService.GetPullRequest(repo, number)
352+
modelService.GetPullRequest(repoOwner, LocalRepository.Name, number)
353353
.TakeLast(1)
354354
.ObserveOn(RxApp.MainThreadScheduler)
355355
.Catch<IPullRequestModel, Exception>(ex =>
@@ -359,23 +359,23 @@ public override void Initialize(ViewWithData data)
359359
IsLoading = IsBusy = false;
360360
return Observable.Empty<IPullRequestModel>();
361361
})
362-
.Subscribe(x => Load(repo, x).Forget());
362+
.Subscribe(x => Load(repoOwner, x).Forget());
363363
}
364364

365365
/// <summary>
366366
/// Loads the view model from octokit models.
367367
/// </summary>
368-
/// <param name="remoteRepository">The remote repository.</param>
368+
/// <param name="remoteRepositoryOwner">The owner of the remote repository.</param>
369369
/// <param name="pullRequest">The pull request model.</param>
370-
public async Task Load(IRemoteRepositoryModel remoteRepository, IPullRequestModel pullRequest)
370+
public async Task Load(string remoteRepositoryOwner, IPullRequestModel pullRequest)
371371
{
372-
Guard.ArgumentNotNull(remoteRepository, nameof(remoteRepository));
372+
Guard.ArgumentNotNull(remoteRepositoryOwner, nameof(remoteRepositoryOwner));
373373

374374
try
375375
{
376376
var firstLoad = (Model == null);
377377
Model = pullRequest;
378-
RemoteRepository = remoteRepository;
378+
RemoteRepositoryOwner = remoteRepositoryOwner;
379379
Session = await sessionManager.GetSession(pullRequest);
380380
Title = Resources.PullRequestNavigationItemText + " #" + pullRequest.Number;
381381

src/GitHub.App/ViewModels/PullRequestListViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ void DoOpenPullRequest(object pullRequest)
331331
{
332332
Data = new PullRequestDetailArgument
333333
{
334-
Repository = SelectedRepository,
334+
RepositoryOwner = SelectedRepository.Owner,
335335
Number = (int)pullRequest,
336336
}
337337
};

src/GitHub.Exports.Reactive/ViewModels/IPullRequestDetailViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ public interface IPullRequestDetailViewModel : IViewModel, IHasLoading, IHasBusy
8383
ILocalRepositoryModel LocalRepository { get; }
8484

8585
/// <summary>
86-
/// Gets the remote repository that contains the pull request.
86+
/// Gets the owner of the remote repository that contains the pull request.
8787
/// </summary>
8888
/// <remarks>
8989
/// The remote repository may be different from the local repository if the local
9090
/// repository is a fork and the user is viewing pull requests from the parent repository.
9191
/// </remarks>
92-
IRemoteRepositoryModel RemoteRepository { get; }
92+
string RemoteRepositoryOwner { get; }
9393

9494
/// <summary>
9595
/// Gets a string describing how to display the pull request's source branch.

src/GitHub.Exports/Settings/PkgCmdID.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public static class PkgCmdIDList
99
public const int idGitHubToolbar = 0x1120;
1010
public const int showGitHubPaneCommand = 0x200;
1111
public const int openPullRequestsCommand = 0x201;
12+
public const int showCurrentPullRequestCommand = 0x202;
1213
public const int backCommand = 0x300;
1314
public const int forwardCommand = 0x301;
1415
public const int refreshCommand = 0x302;

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@
311311
<Compile Include="Helpers\ActiveDocumentSnapshot.cs" />
312312
<Compile Include="Menus\OpenLink.cs" />
313313
<Compile Include="Menus\LinkMenuBase.cs" />
314+
<Compile Include="Menus\ShowCurrentPullRequest.cs" />
314315
<Compile Include="Menus\OpenPullRequests.cs" />
315316
<Compile Include="Menus\ShowGitHubPane.cs" />
316317
<Compile Include="Menus\AddConnection.cs" />

0 commit comments

Comments
 (0)