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

Commit

Permalink
Merge branch 'master' into fixes/remove-experimental-PR-file-margin
Browse files Browse the repository at this point in the history
  • Loading branch information
jcansdale authored Mar 17, 2020
2 parents aef87ca + 4479000 commit 0db9174
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 59 deletions.
37 changes: 15 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,18 @@ jobs:
path: ${{ env.vsixContainer }}

# We need to run '**\bin\**\*Tests.dll'
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.App.UnitTests\bin\${{ env.config }}\net46\GitHub.App.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.Exports.Reactive.UnitTests\bin\${{ env.config }}\net46\GitHub.Exports.Reactive.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.Exports.UnitTests\bin\${{ env.config }}\net46\GitHub.Exports.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.Extensions.UnitTests\bin\${{ env.config }}\net46\GitHub.Extensions.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.InlineReviews.UnitTests\bin\${{ env.config }}\net46\GitHub.InlineReviews.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.Services.Vssdk.UnitTests\bin\${{ env.config }}\net461\GitHub.Services.Vssdk.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.StartPage.UnitTests\bin\${{ env.config }}\net46\GitHub.StartPage.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.TeamFoundation.UnitTests\bin\${{ env.config }}\net46\GitHub.TeamFoundation.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.UI.UnitTests\bin\${{ env.config }}\net46\GitHub.UI.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\GitHub.VisualStudio.UnitTests\bin\${{ env.config }}\net46\GitHub.VisualStudio.UnitTests.dll
continue-on-error: true
- run: vstest.console /TestAdapterPath:test /Settings:test\test.runsettings test\MetricsTests\MetricsTests\bin\${{ env.config }}\MetricsTests.dll
continue-on-error: true
- name: Run unit tests
shell: bash
run: |
vstest.console /TestAdapterPath:test /Settings:test/test.runsettings \
test/GitHub.App.UnitTests/bin/${{ env.config }}/net46/GitHub.App.UnitTests.dll \
test/GitHub.Exports.Reactive.UnitTests/bin/${{ env.config }}/net46/GitHub.Exports.Reactive.UnitTests.dll \
test/GitHub.Exports.UnitTests/bin/${{ env.config }}/net46/GitHub.Exports.UnitTests.dll \
test/GitHub.Extensions.UnitTests/bin/${{ env.config }}/net46/GitHub.Extensions.UnitTests.dll \
test/GitHub.InlineReviews.UnitTests/bin/${{ env.config }}/net46/GitHub.InlineReviews.UnitTests.dll \
test/GitHub.Services.Vssdk.UnitTests/bin/${{ env.config }}/net461/GitHub.Services.Vssdk.UnitTests.dll \
test/GitHub.StartPage.UnitTests/bin/${{ env.config }}/net46/GitHub.StartPage.UnitTests.dll \
test/GitHub.TeamFoundation.UnitTests/bin/${{ env.config }}/net46/GitHub.TeamFoundation.UnitTests.dll \
test/GitHub.UI.UnitTests/bin/${{ env.config }}/net46/GitHub.UI.UnitTests.dll \
test/GitHub.VisualStudio.UnitTests/bin/${{ env.config }}/net46/GitHub.VisualStudio.UnitTests.dll \
test/MetricsTests/MetricsTests/bin/${{ env.config }}/MetricsTests.dll
21 changes: 1 addition & 20 deletions src/GitHub.App/ViewModels/Dialog/LoginCredentialsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.ComponentModel.Composition;
using System.Reactive.Linq;
using GitHub.App;
using GitHub.Primitives;
using GitHub.Services;
using ReactiveUI;

Expand All @@ -28,8 +26,7 @@ public LoginCredentialsViewModel(
(x, y) => x.Value || y.Value
).ToProperty(this, vm => vm.IsLoginInProgress);

UpdateLoginMode();
connectionManager.Connections.CollectionChanged += (_, __) => UpdateLoginMode();
LoginMode = LoginMode.DotComOrEnterprise;

Done = Observable.Merge(
loginToGitHubViewModel.Login,
Expand All @@ -55,21 +52,5 @@ public LoginMode LoginMode
public bool IsLoginInProgress { get { return isLoginInProgress.Value; } }

public IObservable<object> Done { get; }

void UpdateLoginMode()
{
var result = LoginMode.DotComOrEnterprise;

foreach (var connection in ConnectionManager.Connections)
{
if (connection.IsLoggedIn)
{
result &= ~((connection.HostAddress == HostAddress.GitHubDotComHostAddress) ?
LoginMode.DotComOnly : LoginMode.EnterpriseOnly);
}
}

LoginMode = result;
}
}
}
10 changes: 10 additions & 0 deletions src/GitHub.App/ViewModels/GitHubPane/GitHubPaneViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ public GitHubPaneViewModel(
},
currentPage.Select(x => x is IOpenInBrowser));

BrowseRepository = ReactiveCommand.Create(
() =>
{
var url = LocalRepository.CloneUrl.ToRepositoryUrl();
if (url != null) browser.OpenUrl(url);
},
currentPage.Select(x => x is IOpenInBrowser));

help = ReactiveCommand.Create(() => { });
help.Subscribe(_ =>
{
Expand Down Expand Up @@ -531,5 +539,7 @@ static Regex CreateRoute(string route)
var routeFormat = "^" + new Regex("(:([a-z]+))\\b").Replace(route, @"(?<$2>[\w_.\-=]+)") + "$";
return new Regex(routeFormat, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
}

public ReactiveCommand<Unit, Unit> BrowseRepository { get; }
}
}
16 changes: 9 additions & 7 deletions src/GitHub.InlineReviews/Services/PullRequestStatusBarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async Task RefreshCurrentSession(LocalRepositoryModel repository, IPullRequestSe
return;
}

var viewModel = CreatePullRequestStatusViewModel(session);
var viewModel = CreatePullRequestStatusViewModel(repository, session);
ShowStatus(viewModel);
}

Expand Down Expand Up @@ -155,13 +155,15 @@ async Task<bool> IsDotComOrEnterpriseRepository(LocalRepositoryModel repository)
return false;
}

PullRequestStatusViewModel CreatePullRequestStatusViewModel(IPullRequestSession session)
PullRequestStatusViewModel CreatePullRequestStatusViewModel(LocalRepositoryModel repository, IPullRequestSession session)
{
var pullRequestStatusViewModel = new PullRequestStatusViewModel(openPullRequestsCommand, showCurrentPullRequestCommand);
var pullRequest = session?.PullRequest;
pullRequestStatusViewModel.Number = pullRequest?.Number;
pullRequestStatusViewModel.Title = pullRequest?.Title;
return pullRequestStatusViewModel;
return new PullRequestStatusViewModel(openPullRequestsCommand, showCurrentPullRequestCommand)
{
Number = session?.PullRequest?.Number,
Title = session?.PullRequest?.Title,
RepositoryName = repository?.Name,
RepositoryOwner = repository?.Owner,
};
}

PullRequestStatusView ShowStatus(PullRequestStatusViewModel pullRequestStatusViewModel = null)
Expand Down
28 changes: 28 additions & 0 deletions src/GitHub.InlineReviews/ViewModels/PullRequestStatusViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class PullRequestStatusViewModel : INotifyPropertyChanged
{
int? number;
string title;
string repositoryName;
string repositoryOwner;

public PullRequestStatusViewModel(ICommand openPullRequestsCommand, ICommand showCurrentPullRequestCommand)
{
Expand Down Expand Up @@ -41,6 +43,32 @@ public string Title
}
}

public string RepositoryOwner
{
get { return repositoryOwner; }
set
{
if (repositoryOwner != value)
{
repositoryOwner = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RepositoryOwner)));
}
}
}

public string RepositoryName
{
get { return repositoryName; }
set
{
if (repositoryName != value)
{
repositoryName = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(RepositoryName)));
}
}
}

public ICommand OpenPullRequestsCommand { get; }
public ICommand ShowCurrentPullRequestCommand { get; }

Expand Down
5 changes: 4 additions & 1 deletion src/GitHub.InlineReviews/Views/PullRequestStatusView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
Fill="White"
VerticalAlignment="Bottom"
Margin="0 0 4 0 "
Icon="git_pull_request" />
Icon="mark_github" />
<TextBlock VerticalAlignment="Center">
<Run Text="{Binding RepositoryOwner}" /> / <Run Text="{Binding RepositoryName}" />
</TextBlock>
</StackPanel>
</Button>
<Grid.ToolTip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@
<Separator Margin="5,-2,5,0"
Foreground="{DynamicResource GitHubPaneTitleBrush}"
Style="{StaticResource TitleVerticalSeparator}" />
<TextBlock Margin="0,-5,0,0"
VerticalAlignment="Center"
Foreground="{DynamicResource GitHubVsGrayText}"
Text="{Binding LocalRepository.Name}" />
</StackPanel>
<ghfvs:GitHubActionLink Margin="0,-2.5,0,0" Command="{Binding BrowseRepository}" Content="{Binding LocalRepository.Name}" />
</StackPanel>

<Separator Margin="0,0,0,2"
DockPanel.Dock="Top"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ public async Task AllowsLoginFromEnterpriseAfterGitHubLoginHasFailedAsync()
public class TheLoginModeProperty : TestBaseClass
{
[Test]
public void LoginModeTracksAvailableConnections()
public void LoginModeIgnoresAvailableConnections()
{
// We always want to option to log-in to GitHub or GitHub Enterprise

var connectionManager = Substitute.For<IConnectionManager>();
var connections = new ObservableCollectionEx<IConnection>();
var gitHubLogin = Substitute.For<ILoginToGitHubViewModel>();
Expand All @@ -96,13 +98,13 @@ public void LoginModeTracksAvailableConnections()
Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));

connections.Add(enterpriseConnection);
Assert.That(LoginMode.DotComOnly, Is.EqualTo(loginViewModel.LoginMode));
Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));

connections.Add(gitHubConnection);
Assert.That(LoginMode.None, Is.EqualTo(loginViewModel.LoginMode));
Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));

connections.RemoveAt(0);
Assert.That(LoginMode.EnterpriseOnly, Is.EqualTo(loginViewModel.LoginMode));
Assert.That(LoginMode.DotComOrEnterprise, Is.EqualTo(loginViewModel.LoginMode));
}
}

Expand Down

0 comments on commit 0db9174

Please sign in to comment.