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

Commit d4daa1e

Browse files
committed
Merge branch 'master' into refactor/vs-commands
2 parents dc1209c + d25f6a4 commit d4daa1e

File tree

57 files changed

+1257
-397
lines changed

Some content is hidden

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

57 files changed

+1257
-397
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
Hi there! We're thrilled that you'd like to contribute to the __GitHub Extension for Visual Studio__. Your help is essential for keeping it great.
99

10+
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE.md).
11+
1012
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to uphold this code.
1113

1214
## Submitting a pull request

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2.4.3.{build}'
1+
version: '2.4.4.{build}'
22
skip_tags: true
33
install:
44
- ps: |

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +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 enabled SAML single sign-on, you must create and authorize a personal access token to access protected content. 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). 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)."
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.
11+
12+
### Scopes for personal access tokens
13+
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)
19+
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)."
1123

1224
1. In Visual Studio, select **Team Explorer** from the **View** menu.
1325
![Team Explorer in the view menu](images/view_team_explorer.png)
@@ -16,4 +28,13 @@ Before you authenticate, you must already have a GitHub or GitHub Enterprise acc
1628
3. Click the **Connect** link in the GitHub section. If you are already connected to a GitHub instance and want to connect to another, this link will not be visible; instead click **Manage Connections** and then **Connect to GitHub**.
1729
![Connect to GitHub in the manage connections dropdown in the Team Explorer pane](images/connect_to_github.png)
1830
4. In the **Connect to GitHub dialog** choose **GitHub** or **GitHub Enterprise**, depending on which product you're using.
19-
5. Type your credentials, then click **Sign In**.
31+
32+
**GitHub option**:
33+
![Connect to GitHub dialog view](images/connect-to-github-dialog.png)
34+
- To sign in with credentials, enter either username or email and password.
35+
- To sign in with SSO, select `Sign in with your browser`.
36+
37+
**GitHub Enterprise option**:
38+
![Connect to GitHub Enterprise dialog view](images/connect-to-github-enterprise-dialog.png)
39+
- To sign in with credentials, first enter GitHub Enterprise server address. Once a valid server address is entered, a `Token` field appears and a valid token can be entered to sign in.
40+
- To sign in with SSO, first enter the GitHub Enterprise server address. Once a valid server address is entered, select `Sign in with your browser`. Follow the steps to authenticate with your SSO provider.
41 KB
Loading
36.9 KB
Loading

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/Services/EnterpriseCapabilitiesService.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,29 @@ public EnterpriseCapabilitiesService(
3030

3131
public async Task<EnterpriseLoginMethods> ProbeLoginMethods(Uri enterpriseBaseUrl)
3232
{
33-
// It's important that we don't use our cached credentials on this connection, as they
34-
// may be wrong - we're trying to log in after all.
35-
var hostAddress = HostAddress.Create(enterpriseBaseUrl);
36-
var connection = new Octokit.Connection(program.ProductHeader, hostAddress.ApiUri);
37-
var meta = await GetMetadata(connection).ConfigureAwait(false);
38-
var result = EnterpriseLoginMethods.Token;
33+
try
34+
{
35+
// It's important that we don't use our cached credentials on this connection, as they
36+
// may be wrong - we're trying to log in after all.
37+
var hostAddress = HostAddress.Create(enterpriseBaseUrl);
38+
var connection = new Octokit.Connection(program.ProductHeader, hostAddress.ApiUri);
39+
var meta = await GetMetadata(connection).ConfigureAwait(false);
40+
var result = EnterpriseLoginMethods.Token;
41+
42+
if (meta.VerifiablePasswordAuthentication != false) result |= EnterpriseLoginMethods.UsernameAndPassword;
3943

40-
if (meta.VerifiablePasswordAuthentication) result |= EnterpriseLoginMethods.UsernameAndPassword;
44+
if (meta.InstalledVersion != null)
45+
{
46+
var version = new Version(meta.InstalledVersion);
47+
if (version >= MinimumOAuthVersion) result |= EnterpriseLoginMethods.OAuth;
48+
}
4149

42-
if (meta.InstalledVersion != null)
50+
return result;
51+
}
52+
catch
4353
{
44-
var version = new Version(meta.InstalledVersion);
45-
if (version >= MinimumOAuthVersion) result |= EnterpriseLoginMethods.OAuth;
54+
return EnterpriseLoginMethods.Token | EnterpriseLoginMethods.UsernameAndPassword;
4655
}
47-
48-
return result;
4956
}
5057

5158
private async Task<EnterpriseMeta> GetMetadata(IConnection connection)
@@ -56,9 +63,10 @@ private async Task<EnterpriseMeta> GetMetadata(IConnection connection)
5663
}
5764

5865
[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "Created via Octokit reflection")]
59-
class EnterpriseMeta : Meta
66+
class EnterpriseMeta
6067
{
6168
public string InstalledVersion { get; private set; }
69+
public bool? VerifiablePasswordAuthentication { get; private set; }
6270
}
6371
}
6472
}

src/GitHub.App/Services/TeamExplorerContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void Refresh()
7676

7777
if (newRepositoryPath != repositoryPath)
7878
{
79-
log.Debug("Fire PropertyChanged event for ActiveRepository");
79+
log.Debug("ActiveRepository changed to {CloneUrl} @ {Path}", repo?.CloneUrl, newRepositoryPath);
8080
ActiveRepository = repo;
8181
}
8282
else if (newBranchName != branchName)

src/GitHub.App/ViewModels/Dialog/LoginToGitHubForEnterpriseViewModel.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,14 @@ async void EnterpriseUrlChanged(string url, bool valid)
140140

141141
var enterpriseInstance = false;
142142
var loginMethods = (EnterpriseLoginMethods?)null;
143+
var uri = new UriBuilder(url).Uri;
143144

144-
try
145-
{
146-
var uri = new UriBuilder(url).Uri;
147-
ProbeStatus = EnterpriseProbeStatus.Checking;
145+
ProbeStatus = EnterpriseProbeStatus.Checking;
148146

149-
if (await enterpriseCapabilities.Probe(uri) == EnterpriseProbeResult.Ok)
150-
{
151-
loginMethods = await enterpriseCapabilities.ProbeLoginMethods(uri);
152-
enterpriseInstance = true;
153-
}
154-
}
155-
catch
147+
if (await enterpriseCapabilities.Probe(uri) == EnterpriseProbeResult.Ok)
156148
{
157-
ProbeStatus = EnterpriseProbeStatus.Invalid;
158-
loginMethods = null;
149+
loginMethods = await enterpriseCapabilities.ProbeLoginMethods(uri);
150+
enterpriseInstance = true;
159151
}
160152

161153
if (url == EnterpriseUrl)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
using GitHub.Extensions;
1313
using GitHub.Factories;
1414
using GitHub.Info;
15+
using GitHub.Logging;
1516
using GitHub.Models;
1617
using GitHub.Primitives;
1718
using GitHub.Services;
1819
using GitHub.Services.Vssdk.Commands;
1920
using GitHub.VisualStudio;
2021
using ReactiveUI;
22+
using Serilog;
2123
using OleMenuCommand = Microsoft.VisualStudio.Shell.OleMenuCommand;
2224

2325
namespace GitHub.ViewModels.GitHubPane
@@ -29,6 +31,7 @@ namespace GitHub.ViewModels.GitHubPane
2931
[PartCreationPolicy(CreationPolicy.NonShared)]
3032
public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, IDisposable
3133
{
34+
static readonly ILogger log = LogManager.ForContext<GitHubPaneViewModel>();
3235
static readonly Regex pullUri = CreateRoute("/:owner/:repo/pull/:number");
3336

3437
readonly IViewViewModelFactory viewModelFactory;
@@ -346,18 +349,22 @@ async Task NavigateTo<TViewModel>(Func<TViewModel, Task> initialize, Func<TViewM
346349

347350
async Task UpdateContent(ILocalRepositoryModel repository)
348351
{
352+
log.Debug("UpdateContent called with {CloneUrl}", repository?.CloneUrl);
353+
349354
LocalRepository = repository;
350355
Connection = null;
351356
Content = null;
352357
navigator.Clear();
353358

354359
if (repository == null)
355360
{
361+
log.Debug("Not a git repository: {CloneUrl}", repository?.CloneUrl);
356362
Content = notAGitRepository;
357363
return;
358364
}
359365
else if (string.IsNullOrWhiteSpace(repository.CloneUrl))
360366
{
367+
log.Debug("Not a GitHub repository: {CloneUrl}", repository?.CloneUrl);
361368
Content = notAGitHubRepository;
362369
return;
363370
}
@@ -375,16 +382,19 @@ async Task UpdateContent(ILocalRepositoryModel repository)
375382

376383
if (Connection?.IsLoggedIn == true)
377384
{
385+
log.Debug("Found a GitHub repository: {CloneUrl}", repository?.CloneUrl);
378386
Content = navigator;
379387
await ShowDefaultPage();
380388
}
381389
else
382390
{
391+
log.Debug("Found a a GitHub repository but not logged in: {CloneUrl}", repository?.CloneUrl);
383392
Content = loggedOut;
384393
}
385394
}
386395
else
387396
{
397+
log.Debug("Not a GitHub repository: {CloneUrl}", repository?.CloneUrl);
388398
Content = notAGitHubRepository;
389399
}
390400
}

0 commit comments

Comments
 (0)