Disambiguate repositories in the recent group
Автор
Markus Olsson

Коммитер
Markus Olsson
месяц назад 
Файлов изменено: 1
+28
–8
3d0680a
app/src/.../group-repositories.ts
+28
–8
@@ -109,23 +109,35 @@ | ||
.sort(([xKey], [yKey]) => compare(xKey, yKey)) | ||
.map(([, { group, repos }]) => ({ | ||
identifier: group, | ||
items: toSortedListItems(group, repos, localRepositoryStateLookup), | ||
items: toSortedListItems( | ||
group, | ||
repos, | ||
localRepositoryStateLookup, | ||
groups | ||
), | ||
})) | ||
} | ||
const toSortedListItems = ( | ||
group: RepositoryListGroup, | ||
repositories: ReadonlyArray<Repositoryish>, | ||
localRepositoryStateLookup: ReadonlyMap<number, ILocalRepositoryState> | ||
localRepositoryStateLookup: ReadonlyMap<number, ILocalRepositoryState>, | ||
groups: Map<string, RepoGroupItem> | ||
): IRepositoryListItem[] => { | ||
const names = repositories.reduce( | ||
(map, repo) => map.set(repo.name, (map.get(repo.name) ?? 0) + 1), | ||
new Map<string, number>() | ||
) | ||
const groupNames = new Map<string, number>() | ||
const allNames = new Map<string, number>() | ||
for (const groupItem of groups.values()) { | ||
for (const r of groupItem.repos) { | ||
allNames.set(r.name, (allNames.get(r.name) ?? 0) + 1) | ||
if (groupItem.group === group) { | ||
groupNames.set(r.name, (groupNames.get(r.name) ?? 0) + 1) | ||
} | ||
} | ||
} | ||
return repositories | ||
.map(r => { | ||
const nameCount = names.get(r.name) ?? 0 | ||
const repoState = localRepositoryStateLookup.get(r.id) | ||
return { | ||
@@ -133,7 +145,15 @@ | ||
r instanceof Repository ? [r.alias ?? r.name, nameOf(r)] : [r.name], | ||
id: r.id.toString(), | ||
repository: r, | ||
needsDisambiguation: nameCount > 1 && group.kind === 'enterprise', | ||
needsDisambiguation: | ||
// If the repository is in the enterprise group and has a duplicate | ||
// name in the group, we need to disambiguate it. We don't have to | ||
// disambiguate repositories in the 'dotcom' group because they are | ||
// already grouped by owner. If the repository is in the 'recent' | ||
// group and has a duplicate name in any group, we need to | ||
// disambiguate it. | ||
((groupNames.get(r.name) ?? 0) > 1 && group.kind === 'enterprise') || | ||
((allNames.get(r.name) ?? 0) > 1 && group.kind === 'recent'), | ||
aheadBehind: repoState?.aheadBehind ?? null, | ||
changedFilesCount: repoState?.changedFilesCount ?? 0, | ||
} |
Cherry-pick
Команда cherry-pick позволяет выбрать отдельные коммиты из одной ветки и применить их к другой.