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

Commit 2df68b1

Browse files
authored
Merge branch 'master' into feature/show-current-pr
2 parents 1205790 + 30b5ad0 commit 2df68b1

File tree

46 files changed

+317
-204
lines changed

Some content is hidden

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

46 files changed

+317
-204
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

ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Hello! Please read the contributing guidelines before submitting an issue regarding the GitHub Extension for Visual Studio.
22

3-
- GitHub Extension for Visual Studio version:
3+
- GitHub Extension for Visual Studio version:
44
- Visual Studio version:
55

66
__What happened__ (with steps, logs and screenshots, if possible)

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ 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 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.
11+
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)."
13+
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`.
15+
1116

1217
1. In Visual Studio, select **Team Explorer** from the **View** menu.
1318
![Team Explorer in the view menu](images/view_team_explorer.png)
@@ -16,4 +21,13 @@ Before you authenticate, you must already have a GitHub or GitHub Enterprise acc
1621
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**.
1722
![Connect to GitHub in the manage connections dropdown in the Team Explorer pane](images/connect_to_github.png)
1823
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**.
24+
25+
**GitHub option**:
26+
![Connect to GitHub dialog view](images/connect-to-github-dialog.png)
27+
- To sign in with credentials, enter either username or email and password.
28+
- To sign in with SSO, select `Sign in with your browser`.
29+
30+
**GitHub Enterprise option**:
31+
![Connect to GitHub Enterprise dialog view](images/connect-to-github-enterprise-dialog.png)
32+
- 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.
33+
- 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/Api/ApiClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ public IObservable<PullRequest> GetPullRequestsForRepository(string owner, strin
242242
Guard.ArgumentNotEmptyString(name, nameof(name));
243243

244244
return gitHubClient.PullRequest.GetAllForRepository(owner, name,
245-
new PullRequestRequest {
245+
new PullRequestRequest
246+
{
246247
State = ItemStateFilter.All,
247248
SortProperty = PullRequestSort.Updated,
248249
SortDirection = SortDirection.Descending
@@ -268,7 +269,7 @@ public IObservable<Branch> GetBranches(string owner, string repo)
268269
Guard.ArgumentNotEmptyString(owner, nameof(owner));
269270
Guard.ArgumentNotEmptyString(repo, nameof(repo));
270271

271-
#pragma warning disable CS0618
272+
#pragma warning disable 618
272273
// GetAllBranches is obsolete, but don't want to introduce the change to fix the
273274
// warning in the PR, so disabling for now.
274275
return gitHubClient.Repository.GetAllBranches(owner, repo);

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
@@ -11,11 +11,13 @@
1111
using GitHub.Extensions;
1212
using GitHub.Factories;
1313
using GitHub.Info;
14+
using GitHub.Logging;
1415
using GitHub.Models;
1516
using GitHub.Primitives;
1617
using GitHub.Services;
1718
using GitHub.VisualStudio;
1819
using ReactiveUI;
20+
using Serilog;
1921
using OleMenuCommand = Microsoft.VisualStudio.Shell.OleMenuCommand;
2022

2123
namespace GitHub.ViewModels.GitHubPane
@@ -27,6 +29,7 @@ namespace GitHub.ViewModels.GitHubPane
2729
[PartCreationPolicy(CreationPolicy.NonShared)]
2830
public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, IDisposable
2931
{
32+
static readonly ILogger log = LogManager.ForContext<GitHubPaneViewModel>();
3033
static readonly Regex pullUri = CreateRoute("/:owner/:repo/pull/:number");
3134

3235
readonly IViewViewModelFactory viewModelFactory;
@@ -353,18 +356,22 @@ async Task NavigateTo<TViewModel>(Func<TViewModel, Task> initialize, Func<TViewM
353356

354357
async Task UpdateContent(ILocalRepositoryModel repository)
355358
{
359+
log.Debug("UpdateContent called with {CloneUrl}", repository?.CloneUrl);
360+
356361
LocalRepository = repository;
357362
Connection = null;
358363
Content = null;
359364
navigator.Clear();
360365

361366
if (repository == null)
362367
{
368+
log.Debug("Not a git repository: {CloneUrl}", repository?.CloneUrl);
363369
Content = notAGitRepository;
364370
return;
365371
}
366372
else if (string.IsNullOrWhiteSpace(repository.CloneUrl))
367373
{
374+
log.Debug("Not a GitHub repository: {CloneUrl}", repository?.CloneUrl);
368375
Content = notAGitHubRepository;
369376
return;
370377
}
@@ -382,16 +389,19 @@ async Task UpdateContent(ILocalRepositoryModel repository)
382389

383390
if (Connection?.IsLoggedIn == true)
384391
{
392+
log.Debug("Found a GitHub repository: {CloneUrl}", repository?.CloneUrl);
385393
Content = navigator;
386394
await ShowDefaultPage();
387395
}
388396
else
389397
{
398+
log.Debug("Found a a GitHub repository but not logged in: {CloneUrl}", repository?.CloneUrl);
390399
Content = loggedOut;
391400
}
392401
}
393402
else
394403
{
404+
log.Debug("Not a GitHub repository: {CloneUrl}", repository?.CloneUrl);
395405
Content = notAGitHubRepository;
396406
}
397407
}

0 commit comments

Comments
 (0)