Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/GitHub.App/Services/RepositoryCloneService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using GitHub.Api;
using GitHub.Extensions;
Expand Down Expand Up @@ -69,8 +70,8 @@ public async Task<ViewerRepositoriesModel> ReadViewerRepositories(HostAddress ad
{
var order = new RepositoryOrder
{
Field = RepositoryOrderField.Name,
Direction = OrderDirection.Asc
Field = RepositoryOrderField.PushedAt,
Direction = OrderDirection.Desc
};

var affiliation = new RepositoryAffiliation?[]
Expand All @@ -94,14 +95,17 @@ public async Task<ViewerRepositoriesModel> ReadViewerRepositories(HostAddress ad
.Select(viewer => new ViewerRepositoriesModel
{
Owner = viewer.Login,
Repositories = viewer.Repositories(null, null, null, null, null, null, null, order, affiliation, null)
Repositories = viewer.Repositories(null, null, null, null, affiliation, null, null, order, affiliation, null)
.AllPages()
.Select(repositorySelection).ToList(),
ContributedToRepositories = viewer.RepositoriesContributedTo(100, null, null, null, null, null, null, order, null)
.Nodes
.Select(repositorySelection).ToList(),
Organizations = viewer.Organizations(null, null, null, null).AllPages().Select(org => new
{
org.Login,
Repositories = org.Repositories(null, null, null, null, null, null, null, order, null, null)
.AllPages()
Repositories = org.Repositories(100, null, null, null, null, null, null, order, null, null)
.Nodes
.Select(repositorySelection).ToList()
}).ToDictionary(x => x.Login, x => (IReadOnlyList<RepositoryListItemModel>)x.Repositories),
}).Compile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Globalization;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -118,10 +119,16 @@ public async Task Activate()
.Where(r => r.Owner != results.Owner)
.OrderBy(r => r.Owner)
.Select(x => new RepositoryItemViewModel(x, "Collaborator repositories"));
var repositoriesContributedTo = results.ContributedToRepositories
.Select(x => new RepositoryItemViewModel(x, "Contributed to repositories"));
var orgRepositories = results.Organizations
.OrderBy(x => x.Key)
.SelectMany(x => x.Value.Select(y => new RepositoryItemViewModel(y, x.Key)));
Items = yourRepositories.Concat(collaboratorRepositories).Concat(orgRepositories).ToList();
.SelectMany(x => x.Value.Select(y => new RepositoryItemViewModel(y, GroupName(x, 100))));
Items = yourRepositories
.Concat(collaboratorRepositories)
.Concat(repositoriesContributedTo)
.Concat(orgRepositories)
.ToList();
log.Information("Read {Total} viewer repositories", Items.Count);
ItemsView = CollectionViewSource.GetDefaultView(Items);
ItemsView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(RepositoryItemViewModel.Group)));
Expand All @@ -144,6 +151,17 @@ public async Task Activate()
}
}

static string GroupName(KeyValuePair<string, IReadOnlyList<RepositoryListItemModel>> group, int max)
{
var name = group.Key;
if (group.Value.Count == max)
{
name += $" ({string.Format(CultureInfo.InvariantCulture, Resources.MostRecentlyPushed, max)})";
}

return name;
}

bool FilterItem(object obj)
{
if (obj is IRepositoryItemViewModel item && !string.IsNullOrWhiteSpace(Filter))
Expand Down
1 change: 1 addition & 0 deletions src/GitHub.Exports/Models/ViewerRepositoriesModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class ViewerRepositoriesModel
{
public string Owner { get; set; }
public IReadOnlyList<RepositoryListItemModel> Repositories { get; set; }
public IReadOnlyList<RepositoryListItemModel> ContributedToRepositories { get; set; }
public IDictionary<string, IReadOnlyList<RepositoryListItemModel>> Organizations { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/GitHub.Resources/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/GitHub.Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -845,4 +845,7 @@ https://git-scm.com/download/win</value>
<data name="CouldntFindCorrespondingFile" xml:space="preserve">
<value>Couldn't find file corresponding to '{0}' in the repository. Please do a 'git fetch' or checkout the target pull request.</value>
</data>
<data name="MostRecentlyPushed" xml:space="preserve">
<value>{0} most recently pushed</value>
</data>
</root>