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

Commit 3de07ff

Browse files
authored
Merge branch 'master' into fixes/1799-reduce-footprint-non-GitHub-projects
2 parents 226e325 + ea714ae commit 3de07ff

33 files changed

+486
-101
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/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/ViewModels/Dialog/LoginToGitHubForEnterpriseViewModel.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public LoginToGitHubForEnterpriseViewModel(
6565
this.WhenAnyValue(x => x.EnterpriseUrl, x => x.EnterpriseUrlValidator.ValidationResult)
6666
.Throttle(TimeSpan.FromMilliseconds(500), scheduler)
6767
.ObserveOn(RxApp.MainThreadScheduler)
68-
.Subscribe(x => EnterpriseUrlChanged(x.Item1, x.Item2?.IsValid ?? false));
68+
.Subscribe(x => UpdatingProbeStatus = EnterpriseUrlChanged(x.Item1, x.Item2?.IsValid ?? false));
6969

7070
NavigateLearnMore = ReactiveCommand.CreateAsyncObservable(_ =>
7171
{
@@ -122,13 +122,19 @@ public IReactiveCommand<Unit> NavigateLearnMore
122122
get;
123123
}
124124

125+
public Task UpdatingProbeStatus
126+
{
127+
get;
128+
private set;
129+
}
130+
125131
protected override async Task ResetValidation()
126132
{
127133
EnterpriseUrl = null;
128134
await EnterpriseUrlValidator.ResetAsync();
129135
}
130136

131-
async void EnterpriseUrlChanged(string url, bool valid)
137+
async Task EnterpriseUrlChanged(string url, bool valid)
132138
{
133139
if (!valid)
134140
{

src/GitHub.App/ViewModels/GitHubPane/IssueListViewModelBase.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ void FilterChanged()
246246
{
247247
numberFilter = 0;
248248

249-
if (SearchQuery.StartsWith('#'))
250-
{
251-
int.TryParse(SearchQuery.Substring(1), out numberFilter);
252-
}
249+
int.TryParse(SearchQuery.Substring(SearchQuery.StartsWith('#') ? 1 : 0), out numberFilter);
253250

254251
if (numberFilter == 0)
255252
{

src/GitHub.Exports/Services/IGitHubContextService.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ public interface IGitHubContextService
7171
/// <returns>The resolved commit-ish, blob path and commit SHA for the blob. Path will be null if the commit-ish can be resolved but not the blob.</returns>
7272
(string commitish, string path, string commitSha) ResolveBlob(string repositoryDir, GitHubContext context, string remoteName = "origin");
7373

74+
/// <summary>
75+
/// Find the object-ish (first 8 chars of a blob SHA) from the path to historical blob created by Team Explorer.
76+
/// </summary>
77+
/// <remarks>
78+
/// Team Explorer creates temporary blob files in the following format:
79+
/// C:\Users\me\AppData\Local\Temp\TFSTemp\vctmp21996_181282.IOpenFromClipboardCommand.783ac965.cs
80+
/// The object-ish appears immediately before the file extension and the path contains the folder "TFSTemp".
81+
/// <remarks>
82+
/// <param name="tempFile">The path to a possible Team Explorer temporary blob file.</param>
83+
/// <returns>The target file's object-ish (blob SHA fragment) or null if the path isn't recognized as a Team Explorer blob file.</returns>
84+
string FindObjectishForTFSTempFile(string tempFile);
85+
86+
/// <summary>
87+
/// Find a tree entry in the commit log where a blob appears and return its commit SHA and path.
88+
/// </summary>
89+
/// <remarks>
90+
/// Search back through the commit log for the first tree entry where a blob appears. This operation only takes
91+
/// a fraction of a seond on the `github/VisualStudio` repository even if a tree entry casn't be found.
92+
/// </remarks>
93+
/// <param name="repositoryDir">The target repository directory.</param>
94+
/// <param name="objectish">The fragment of a blob SHA to find.</param>
95+
/// <returns>The commit SHA and blob path or null if the blob can't be found.</returns>
96+
(string commitSha, string blobPath) ResolveBlobFromHistory(string repositoryDir, string objectish);
97+
7498
/// <summary>
7599
/// Check if a file in the working directory has changed since a specified commit-ish.
76100
/// </summary>

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
<Compile Include="Margins\InlineCommentMargin.cs" />
8585
<Compile Include="Margins\InlineCommentMarginVisible.cs" />
8686
<Compile Include="Margins\InlineCommentMarginEnabled.cs" />
87+
<Compile Include="Services\CommentService.cs" />
88+
<Compile Include="Services\ICommentService.cs" />
8789
<Compile Include="PullRequestStatusBarPackage.cs" />
8890
<Compile Include="InlineReviewsPackage.cs" />
8991
<Compile Include="Models\InlineCommentThreadModel.cs" />

src/GitHub.InlineReviews/Peek/InlineCommentPeekableItemSource.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ class InlineCommentPeekableItemSource : IPeekableItemSource
1616
readonly IPullRequestSessionManager sessionManager;
1717
readonly INextInlineCommentCommand nextCommentCommand;
1818
readonly IPreviousInlineCommentCommand previousCommentCommand;
19+
readonly ICommentService commentService;
1920

20-
public InlineCommentPeekableItemSource(
21-
IInlineCommentPeekService peekService,
21+
public InlineCommentPeekableItemSource(IInlineCommentPeekService peekService,
2222
IPullRequestSessionManager sessionManager,
2323
INextInlineCommentCommand nextCommentCommand,
24-
IPreviousInlineCommentCommand previousCommentCommand)
24+
IPreviousInlineCommentCommand previousCommentCommand,
25+
ICommentService commentService)
2526
{
2627
this.peekService = peekService;
2728
this.sessionManager = sessionManager;
2829
this.nextCommentCommand = nextCommentCommand;
2930
this.previousCommentCommand = previousCommentCommand;
31+
this.commentService = commentService;
3032
}
3133

3234
public void AugmentPeekSession(IPeekSession session, IList<IPeekableItem> peekableItems)
@@ -38,7 +40,8 @@ public void AugmentPeekSession(IPeekSession session, IList<IPeekableItem> peekab
3840
session,
3941
sessionManager,
4042
nextCommentCommand,
41-
previousCommentCommand);
43+
previousCommentCommand,
44+
commentService);
4245
viewModel.Initialize().Forget();
4346
peekableItems.Add(new InlineCommentPeekableItem(viewModel));
4447
}

src/GitHub.InlineReviews/Peek/InlineCommentPeekableItemSourceProvider.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ class InlineCommentPeekableItemSourceProvider : IPeekableItemSourceProvider
2020
readonly IPullRequestSessionManager sessionManager;
2121
readonly INextInlineCommentCommand nextCommentCommand;
2222
readonly IPreviousInlineCommentCommand previousCommentCommand;
23+
readonly ICommentService commentService;
2324

2425
[ImportingConstructor]
2526
public InlineCommentPeekableItemSourceProvider(
2627
IInlineCommentPeekService peekService,
2728
IPullRequestSessionManager sessionManager,
2829
INextInlineCommentCommand nextCommentCommand,
29-
IPreviousInlineCommentCommand previousCommentCommand)
30+
IPreviousInlineCommentCommand previousCommentCommand,
31+
ICommentService commentService)
3032
{
3133
this.peekService = peekService;
3234
this.sessionManager = sessionManager;
3335
this.nextCommentCommand = nextCommentCommand;
3436
this.previousCommentCommand = previousCommentCommand;
37+
this.commentService = commentService;
3538
}
3639

3740
public IPeekableItemSource TryCreatePeekableItemSource(ITextBuffer textBuffer)
@@ -40,7 +43,8 @@ public IPeekableItemSource TryCreatePeekableItemSource(ITextBuffer textBuffer)
4043
peekService,
4144
sessionManager,
4245
nextCommentCommand,
43-
previousCommentCommand);
46+
previousCommentCommand,
47+
commentService);
4448
}
4549
}
4650
}

0 commit comments

Comments
 (0)