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

Commit 949591a

Browse files
Merge remote-tracking branch 'origin/master' into features/check-suites
# Conflicts: # src/GitHub.App/Services/PullRequestService.cs # src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs # src/GitHub.Exports/Models/PullRequestDetailModel.cs # src/GitHub.InlineReviews/Services/PullRequestSessionService.cs # test/GitHub.App.UnitTests/ViewModels/GitHubPane/PullRequestDetailViewModelTests.cs
2 parents c2d2cee + a119e89 commit 949591a

File tree

88 files changed

+1305
-486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1305
-486
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ This project adheres to the [Open Code of Conduct][code-of-conduct]. By particip
1313

1414
## Submitting a pull request
1515

16-
0. [Fork][] and clone the repository (see Build Instructions in the [README][readme])
17-
0. Create a new branch: `git checkout -b my-branch-name`
18-
0. Make your change, add tests, and make sure the tests still pass
19-
0. Push to your fork and [submit a pull request][pr]
20-
0. Pat your self on the back and wait for your pull request to be reviewed and merged.
16+
1. [Fork][] and clone the repository (see Build Instructions in the [README][readme])
17+
2. Create a new branch: `git checkout -b my-branch-name`
18+
3. Make your change, add tests, and make sure the tests still pass
19+
4. Push to your fork and [submit a pull request][pr]
20+
5. Pat your self on the back and wait for your pull request to be reviewed and merged.
2121

2222
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
2323

24-
- Follow the existing code's style.
25-
- Write tests.
24+
- Follow the style/format of the existing code.
25+
- Write tests for your changes.
2626
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
2727
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
2828

@@ -38,7 +38,7 @@ There are certain areas of the extension that are restricted in what they can do
3838
### Bug Reporting
3939

4040
Here are a few helpful tips when reporting a bug:
41-
- Verify the bug resides in the GitHub for Visual Studio extension
41+
- Verify that the bug resides in the GitHub for Visual Studio extension
4242
- A lot of functionality provided by this extension resides in the Team Explorer pane, alongside other non-GitHub tools to manage and collaborate on source code, including Visual Studio's Git support, which is owned by Microsoft.
4343
- If this bug not is related to the GitHub extension, visit the [Visual Studio support page](https://www.visualstudio.com/support/support-overview-vs) for help
4444
- Screenshots are very helpful in diagnosing bugs and understanding the state of the extension when it's experiencing problems. Please include them whenever possible.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: Visual Studio 2017
2-
version: '2.5.4.{build}'
2+
version: '2.5.5.{build}'
33
skip_tags: true
44
install:
55
- ps: |

docs/developer/how-viewmodels-are-turned-into-views.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ This is the basis for converting view models to views.
6565

6666
There are currently two top-level controls for our UI:
6767

68-
- [GitHubDialogWindow](../src/GitHub.VisualStudio/Views/Dialog/GitHubDialogWindow.xaml) for the dialog which shows the login, clone, etc views
69-
- [GitHubPaneView](../src/GitHub.VisualStudio/Views/GitHubPane/GitHubPaneView.xaml) for the GitHub pane
68+
- [GitHubDialogWindow](../../src/GitHub.VisualStudio/Views/Dialog/GitHubDialogWindow.xaml) for the dialog which shows the login, clone, etc views
69+
- [GitHubPaneView](../../src/GitHub.VisualStudio/Views/GitHubPane/GitHubPaneView.xaml) for the GitHub pane
7070

7171
In the resources for each of these top-level controls we define a `DataTemplate` like so:
7272

@@ -77,10 +77,10 @@ In the resources for each of these top-level controls we define a `DataTemplate`
7777
</DataTemplate>
7878
```
7979

80-
The `DataTemplate.DataType` here applies the template to all classes inherited from [`GitHub.ViewModels.ViewModelBase`](../src/GitHub.Exports.Reactive/ViewModels/ViewModelBase.cs) [1]. The template defines a single `ContentControl` whose contents are created by a `ViewLocator`.
80+
The `DataTemplate.DataType` here applies the template to all classes inherited from [`GitHub.ViewModels.ViewModelBase`](../../src/GitHub.Exports.Reactive/ViewModels/ViewModelBase.cs) [1]. The template defines a single `ContentControl` whose contents are created by a `ViewLocator`.
8181

82-
The [`ViewLocator`](../src/GitHub.VisualStudio/Views/ViewLocator.cs) class is an `IValueConverter` which then creates an instance of the appropriate view for the view model using MEF.
82+
The [`ViewLocator`](../../src/GitHub.VisualStudio/Views/ViewLocator.cs) class is an `IValueConverter` which then creates an instance of the appropriate view for the view model using MEF.
8383

8484
And thus a view model becomes a view.
8585

86-
[1]: it would be nice to make it apply to all classes that inherit `IViewModel` but unfortunately WPF's `DataTemplate`s don't work with interfaces.
86+
[1]: it would be nice to make it apply to all classes that inherit `IViewModel` but unfortunately WPF's `DataTemplate`s don't work with interfaces.

src/GitHub.App/GitHub.App.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
198198
</Reference>
199199
<Reference Include="System.Web" />
200+
<Reference Include="System.Windows.Forms" />
200201
<Reference Include="System.Xaml" />
201202
<Reference Include="System.Xml.Linq" />
202203
<Reference Include="System.Data.DataSetExtensions" />
@@ -258,6 +259,7 @@
258259
<Compile Include="ViewModels\GitHubPane\LoggedOutViewModel.cs" />
259260
<Compile Include="ViewModels\GitHubPane\NavigationViewModel.cs" />
260261
<Compile Include="ViewModels\GitHubPane\GitHubPaneViewModel.cs" />
262+
<Compile Include="SampleData\PullRequestCheckViewModelDesigner.cs" />
261263
<Compile Include="ViewModels\GitHubPane\PullRequestFilesViewModel.cs" />
262264
<Compile Include="ViewModels\GitHubPane\PullRequestListItemViewModel.cs" />
263265
<Compile Include="ViewModels\GitHubPane\PullRequestListViewModel.cs" />

src/GitHub.App/Models/PullRequestModel.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using GitHub.Primitives;
44
using GitHub.VisualStudio.Helpers;
55
using System.Diagnostics;
6+
using System.Collections.Generic;
67
using GitHub.Extensions;
78

89
namespace GitHub.Models
@@ -124,17 +125,6 @@ public PullRequestStateEnum State
124125
}
125126
}
126127

127-
PullRequestChecksEnum checks;
128-
public PullRequestChecksEnum Checks
129-
{
130-
get { return checks; }
131-
set
132-
{
133-
checks = value;
134-
this.RaisePropertyChange();
135-
}
136-
}
137-
138128
// TODO: Remove these property once maintainer workflow has been merged to master.
139129
public bool IsOpen => State == PullRequestStateEnum.Open;
140130
public bool Merged => State == PullRequestStateEnum.Merged;
@@ -193,4 +183,4 @@ internal string DebuggerDisplay
193183
}
194184
}
195185
}
196-
}
186+
}

src/GitHub.App/Resources.Designer.cs

Lines changed: 21 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GitHub.App/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,10 @@ https://git-scm.com/download/win</value>
321321
<data name="SwitchOriginTitle" xml:space="preserve">
322322
<value>Switch Origin</value>
323323
</data>
324+
<data name="CancelPendingReviewConfirmation" xml:space="preserve">
325+
<value>Are you sure you want to cancel this review? You will lose all your pending comments.</value>
326+
</data>
327+
<data name="CancelPendingReviewConfirmationCaption" xml:space="preserve">
328+
<value>Cancel Review</value>
329+
</data>
324330
</root>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Windows.Media.Imaging;
3+
using GitHub.ViewModels;
4+
using GitHub.ViewModels.GitHubPane;
5+
using ReactiveUI;
6+
7+
namespace GitHub.SampleData
8+
{
9+
public sealed class PullRequestCheckViewModelDesigner : ViewModelBase, IPullRequestCheckViewModel
10+
{
11+
public string Title { get; set; } = "continuous-integration/appveyor/pr";
12+
13+
public string Description { get; set; } = "AppVeyor build failed";
14+
15+
public PullRequestCheckStatus Status { get; set; } = PullRequestCheckStatus.Failure;
16+
17+
public Uri DetailsUrl { get; set; } = new Uri("http://github.com");
18+
19+
public string AvatarUrl { get; set; } = "https://avatars1.githubusercontent.com/u/417571?s=88&v=4";
20+
21+
public BitmapImage Avatar { get; set; } = null;
22+
23+
public ReactiveCommand<object> OpenDetailsUrl { get; set; } = null;
24+
}
25+
}

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Diagnostics.CodeAnalysis;
4-
using System.Reactive;
5-
using System.Text;
6-
using System.Threading.Tasks;
71
using GitHub.Models;
82
using GitHub.Services;
93
using GitHub.ViewModels;
104
using GitHub.ViewModels.GitHubPane;
115
using ReactiveUI;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Diagnostics.CodeAnalysis;
9+
using System.Reactive;
10+
using System.Threading.Tasks;
11+
using GitHub.SampleData;
1212

1313
namespace GitHub.SampleData
1414
{
@@ -96,35 +96,7 @@ public PullRequestDetailViewModelDesigner()
9696

9797
Files = new PullRequestFilesViewModelDesigner();
9898

99-
var defaultAvatar = "pack://application:,,,/GitHub.App;component/Images/default_user_avatar.png";
100-
101-
Checks = new[]
102-
{
103-
new PullRequestCheckViewModel
104-
{
105-
Title = "continuous-integration/appveyor/branch",
106-
Description = "AppVeyor build succeeded",
107-
Status = PullRequestCheckStatusEnum.Success,
108-
AvatarUrl = defaultAvatar,
109-
Avatar = AvatarProvider.CreateBitmapImage(defaultAvatar),
110-
},
111-
new PullRequestCheckViewModel
112-
{
113-
Title = "continuous-integration/appveyor/pr",
114-
Description = "AppVeyor building",
115-
Status = PullRequestCheckStatusEnum.Pending,
116-
AvatarUrl = defaultAvatar,
117-
Avatar = AvatarProvider.CreateBitmapImage(defaultAvatar),
118-
},
119-
new PullRequestCheckViewModel
120-
{
121-
Title = "continuous-integration/appveyor/other",
122-
Description = "AppVeyor build failed",
123-
Status = PullRequestCheckStatusEnum.Failure,
124-
AvatarUrl = defaultAvatar,
125-
Avatar = AvatarProvider.CreateBitmapImage(defaultAvatar),
126-
},
127-
};
99+
Checks = new PullRequestCheckViewModelDesigner[0];
128100
}
129101

130102
public PullRequestDetailModel Model { get; }

src/GitHub.App/SampleData/PullRequestListItemViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public class PullRequestListItemViewModelDesigner : ViewModelBase, IPullRequestL
1717
public int Number { get; set; }
1818
public string Title { get; set; }
1919
public DateTimeOffset UpdatedAt { get; set; }
20-
public PullRequestChecksEnum Checks { get; set; }
20+
public PullRequestChecksState Checks { get; set; }
2121
}
2222
}

src/GitHub.App/Services/GitHubContextService.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class GitHubContextService : IGitHubContextService
5858
static readonly Regex treeishCommitRegex = new Regex($"(?<commit>[a-z0-9]{{40}})(/(?<tree>.+))?", RegexOptions.Compiled);
5959
static readonly Regex treeishBranchRegex = new Regex($"(?<branch>master)(/(?<tree>.+))?", RegexOptions.Compiled);
6060

61+
static readonly Regex tempFileObjectishRegex = new Regex(@"\\TFSTemp\\[^\\]*[.](?<objectish>[a-z0-9]{8})[.][^.\\]*$", RegexOptions.Compiled);
62+
6163
[ImportingConstructor]
6264
public GitHubContextService(IGitHubServiceProvider serviceProvider, IGitService gitService)
6365
{
@@ -305,6 +307,55 @@ public bool TryOpenFile(string repositoryDir, GitHubContext context)
305307
}
306308
}
307309

310+
/// <inheritdoc/>
311+
public string FindObjectishForTFSTempFile(string tempFile)
312+
{
313+
var match = tempFileObjectishRegex.Match(tempFile);
314+
if (match.Success)
315+
{
316+
return match.Groups["objectish"].Value;
317+
}
318+
319+
return null;
320+
}
321+
322+
/// <inheritdoc/>
323+
public (string commitSha, string blobPath) ResolveBlobFromHistory(string repositoryDir, string objectish)
324+
{
325+
using (var repo = gitService.GetRepository(repositoryDir))
326+
{
327+
var blob = repo.Lookup<Blob>(objectish);
328+
if (blob == null)
329+
{
330+
return (null, null);
331+
}
332+
333+
foreach (var commit in repo.Commits)
334+
{
335+
var trees = new Stack<Tree>();
336+
trees.Push(commit.Tree);
337+
338+
while (trees.Count > 0)
339+
{
340+
foreach (var treeEntry in trees.Pop())
341+
{
342+
if (treeEntry.Target == blob)
343+
{
344+
return (commit.Sha, treeEntry.Path);
345+
}
346+
347+
if (treeEntry.TargetType == TreeEntryTargetType.Tree)
348+
{
349+
trees.Push((Tree)treeEntry.Target);
350+
}
351+
}
352+
}
353+
}
354+
355+
return (null, null);
356+
}
357+
}
358+
308359
/// <inheritdoc/>
309360
public bool HasChangesInWorkingDirectory(string repositoryDir, string commitish, string path)
310361
{

src/GitHub.App/Services/ModelService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ IPullRequestModel Create(PullRequestCacheItem prCacheItem)
440440
CommitCount = prCacheItem.CommitCount,
441441
CreatedAt = prCacheItem.CreatedAt,
442442
Head = Create(prCacheItem.Head),
443-
Checks = prCacheItem.Checks ?? PullRequestChecksEnum.None,
444443
State = prCacheItem.State.HasValue ?
445444
prCacheItem.State.Value :
446445
prCacheItem.IsOpen.Value ? PullRequestStateEnum.Open : PullRequestStateEnum.Closed,
@@ -578,7 +577,6 @@ public PullRequestCacheItem(PullRequest pr)
578577

579578
// Nullable for compatibility with old caches.
580579
public PullRequestStateEnum? State { get; set; }
581-
public PullRequestChecksEnum? Checks { get; set; }
582580

583581
// This fields exists only for compatibility with old caches. The State property should be used.
584582
public bool? IsOpen { get; set; }

0 commit comments

Comments
 (0)