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

Commit bfebeae

Browse files
authored
Merge branch 'master' into fixes/1511-Git-UIContext
2 parents d951127 + 6fe4bf1 commit bfebeae

File tree

33 files changed

+660
-275
lines changed

33 files changed

+660
-275
lines changed

docs/getting-started/authenticating-to-github.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ Before you authenticate, you must already have a GitHub or GitHub Enterprise acc
77
- For more information on creating a GitHub account, see "[Signing up for a new GitHub account](https://help.github.com/articles/signing-up-for-a-new-github-account/)".
88
- For a GitHub Enterprise account, contact your GitHub Enterprise site administrator.
99

10-
> **Note:** If your organization is on the [Business plan](https://help.github.com/articles/organization-billing-plans) and has not enabled SAML single sign-on or login with username and passowrd, you must create and authorize a personal access token to access protected content. In addition, SAML single sign-on is not available for GitHub enterprise versions less than 2.12.2.
10+
**Note:** If your organization is on the [Business plan](https://help.github.com/articles/organization-billing-plans) and has not enabled SAML single sign-on or login with username and password, you must create and authorize a personal access token to access protected content. In addition, SAML single sign-on is not available for GitHub enterprise versions less than 2.12.2.
1111

12-
> For more information on authenticating with SAML single sign-on, see "[About authentication with SAML single sign-on](https://help.github.com/articles/about-authentication-with-saml-single-sign-on)."
12+
### Scopes for personal access tokens
1313

14-
> For more information on creating personal access tokens, see "[Creating a personal access token for the command line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line). The required scopes for the personal access token are: `user`, `repo`, `gist`, and `write:public_key`.
14+
The scopes for the personal access token are: `user`, `repo`, `gist`, and `write:public_key`.
15+
- *user* scope: Grants access to the user profile data. We currently use this to display your avatar and check whether your plans lets you publish private repositories.
16+
- *repo* scope: Grants read/write access to code, commit statuses, invitations, collaborators, adding team memberships, and deployment statuses for public and private repositories and organizations. This is needed for all git network operations (push, pull, fetch), and for getting information about the repository you're currently working on.
17+
- *gist* scope: Grants write access to gists. We use this in our gist feature, so you can highlight code and create gists directly from Visual Studio
18+
- *write:public_key* scope: Grants access to creating, listing, and viewing details for public keys. This will allows us to add ssh support to your repositories, if you are unable to go through https (this feature is not available yet, this scope is optional)
1519

20+
For more information on creating personal access tokens, see "[Creating a personal access token for the command line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line).
21+
22+
For more information on authenticating with SAML single sign-on, see "[About authentication with SAML single sign-on](https://help.github.com/articles/about-authentication-with-saml-single-sign-on)."
1623

1724
1. In Visual Studio, select **Team Explorer** from the **View** menu.
1825
![Team Explorer in the view menu](images/view_team_explorer.png)

src/GitHub.App/SampleData/PullRequestListViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public PullRequestListViewModelDesigner()
5858

5959
public IReadOnlyList<IRemoteRepositoryModel> Repositories { get; }
6060
public IRemoteRepositoryModel SelectedRepository { get; set; }
61-
61+
public IPullRequestModel CheckedOutPullRequest { get; set; }
6262
public ITrackingCollection<IPullRequestModel> PullRequests { get; set; }
6363
public IPullRequestModel SelectedPullRequest { get; set; }
6464

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public class PullRequestListViewModel : PanePageViewModelBase, IPullRequestListV
4141
public PullRequestListViewModel(
4242
IModelServiceFactory modelServiceFactory,
4343
IPackageSettings settings,
44+
IPullRequestSessionManager sessionManager,
4445
IVisualStudioBrowser visualStudioBrowser)
4546
{
4647
Guard.ArgumentNotNull(modelServiceFactory, nameof(modelServiceFactory));
4748
Guard.ArgumentNotNull(settings, nameof(settings));
49+
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
4850
Guard.ArgumentNotNull(visualStudioBrowser, nameof(visualStudioBrowser));
4951

5052
constructing = true;
@@ -100,6 +102,19 @@ public PullRequestListViewModel(
100102
OpenPullRequestOnGitHub = ReactiveCommand.Create();
101103
OpenPullRequestOnGitHub.Subscribe(x => DoOpenPullRequestOnGitHub((int)x));
102104

105+
// Get the current pull request session and the selected repository. When the session's
106+
// repository is the same as our selected repository set CheckedOutPullRequest to the
107+
// current session's model, so that the checked out PR can be highlighted.
108+
Observable.CombineLatest(
109+
sessionManager.WhenAnyValue(x => x.CurrentSession),
110+
this.WhenAnyValue(x => x.SelectedRepository),
111+
(s, r) => new { Session = s, Repository = r })
112+
.Subscribe(x =>
113+
{
114+
CheckedOutPullRequest = x.Session?.RepositoryOwner == x.Repository?.Owner ?
115+
x.Session?.PullRequest : null;
116+
});
117+
103118
constructing = false;
104119
}
105120

@@ -245,6 +260,13 @@ public IPullRequestModel SelectedPullRequest
245260
set { this.RaiseAndSetIfChanged(ref selectedPullRequest, value); }
246261
}
247262

263+
IPullRequestModel checkedOutPullRequest;
264+
public IPullRequestModel CheckedOutPullRequest
265+
{
266+
get { return checkedOutPullRequest; }
267+
set { this.RaiseAndSetIfChanged(ref checkedOutPullRequest, value); }
268+
}
269+
248270
IReadOnlyList<PullRequestState> states;
249271
public IReadOnlyList<PullRequestState> States
250272
{

src/GitHub.Exports.Reactive/ViewModels/GitHubPane/IPullRequestListViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public interface IPullRequestListViewModel : ISearchablePageViewModel, IOpenInBr
3333
IRemoteRepositoryModel SelectedRepository { get; set; }
3434
ITrackingCollection<IPullRequestModel> PullRequests { get; }
3535
IPullRequestModel SelectedPullRequest { get; }
36+
IPullRequestModel CheckedOutPullRequest { get; }
3637
IReadOnlyList<PullRequestState> States { get; set; }
3738
PullRequestState SelectedState { get; set; }
3839
ObservableCollection<IAccount> Authors { get; }

src/GitHub.Exports/Models/UsageModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace GitHub.Models
1+
using System;
2+
3+
namespace GitHub.Models
24
{
35
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "It'll use reflection by default and we're fine with that")]
46
public struct UsageModel
57
{
8+
public Guid Guid { get; set; }
69
public bool IsGitHubUser { get; set; }
710
public bool IsEnterpriseUser { get; set; }
811
public string AppVersion { get; set; }

src/GitHub.Exports/Primitives/UriString.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ bool ParseScpSyntax(string scpString)
129129
public bool IsValidUri => url != null;
130130

131131
/// <summary>
132-
/// Attempts a best-effort to convert the remote origin to a GitHub Repository URL.
132+
/// Attempts a best-effort to convert the remote origin to a GitHub Repository URL,
133+
/// optionally changing the owner.
133134
/// </summary>
135+
/// <param name="owner">The owner to use, if null uses <see cref="Owner"/>.</param>
134136
/// <returns>A converted uri, or the existing one if we can't convert it (which might be null)</returns>
135-
public Uri ToRepositoryUrl()
137+
public Uri ToRepositoryUrl(string owner = null)
136138
{
137139
// we only want to process urls that represent network resources
138140
if (!IsScpUri && (!IsValidUri || IsFileUri)) return url;
@@ -141,11 +143,15 @@ public Uri ToRepositoryUrl()
141143
? url.Scheme
142144
: Uri.UriSchemeHttps;
143145

146+
var nameWithOwner = owner != null && Owner != null ?
147+
string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, RepositoryName) :
148+
NameWithOwner;
149+
144150
return new UriBuilder
145151
{
146152
Scheme = scheme,
147153
Host = Host,
148-
Path = NameWithOwner,
154+
Path = nameWithOwner,
149155
Port = url?.Port == 80
150156
? -1
151157
: (url?.Port ?? -1)

src/GitHub.Exports/Services/IUsageService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public interface IUsageService
2929
/// <param name="lastUpdated">The last updated date.</param>
3030
/// <returns>True if the last updated date is the same month as today; otherwise false.</returns>
3131
bool IsSameMonth(DateTimeOffset lastUpdated);
32+
33+
/// <summary>
34+
/// Gets a GUID that anonymously represents the user.
35+
/// </summary>
36+
Task<Guid> GetUserGuid();
3237

3338
/// <summary>
3439
/// Starts a timer.

src/GitHub.Exports/Services/IVSUIContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public VSUIContextChangedEventArgs(bool activated)
2020
public interface IVSUIContext
2121
{
2222
bool IsActive { get; }
23-
event EventHandler<VSUIContextChangedEventArgs> UIContextChanged;
23+
void WhenActivated(Action action);
2424
}
2525
}

src/GitHub.InlineReviews/ViewModels/InlineCommentThreadViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override Uri GetCommentUrl(int id)
5454
return new Uri(string.Format(
5555
CultureInfo.InvariantCulture,
5656
"{0}/pull/{1}#discussion_r{2}",
57-
Session.LocalRepository.CloneUrl.ToRepositoryUrl(),
57+
Session.LocalRepository.CloneUrl.ToRepositoryUrl(Session.RepositoryOwner),
5858
Session.PullRequest.Number,
5959
id));
6060
}

src/GitHub.TeamFoundation.14/GitHub.TeamFoundation.14.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
<HintPath>..\..\packages\Microsoft.VisualStudio.ComponentModelHost.14.0.25424\lib\net45\Microsoft.VisualStudio.ComponentModelHost.dll</HintPath>
8080
<Private>True</Private>
8181
</Reference>
82+
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
83+
<HintPath>..\..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll</HintPath>
84+
<Private>True</Private>
85+
</Reference>
8286
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
8387
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.14.0.14.3.25407\lib\Microsoft.VisualStudio.Shell.14.0.dll</HintPath>
8488
<Private>True</Private>
@@ -87,6 +91,15 @@
8791
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.10.0.10.0.30319\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll</HintPath>
8892
<Private>True</Private>
8993
</Reference>
94+
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
95+
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
96+
<Private>True</Private>
97+
</Reference>
98+
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
99+
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
100+
<Private>True</Private>
101+
<Aliases>global</Aliases>
102+
</Reference>
90103
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
91104
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>
92105
<Private>True</Private>
@@ -95,6 +108,10 @@
95108
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll</HintPath>
96109
<Private>True</Private>
97110
</Reference>
111+
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
112+
<HintPath>..\..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
113+
<Private>True</Private>
114+
</Reference>
98115
<Reference Include="PresentationCore" />
99116
<Reference Include="PresentationFramework" />
100117
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">

0 commit comments

Comments
 (0)