mirror of
https://github.com/desktop/desktop
synced 2024-09-19 08:02:22 +00:00
Only prune forked remotes without local branches
Co-Authored-By: Markus Olsson <634063+niik@users.noreply.github.com>
This commit is contained in:
parent
8518282f31
commit
1bb8731d85
|
@ -1642,16 +1642,17 @@ export class GitStore extends BaseStore {
|
|||
|
||||
public async pruneForkedRemotes(openPRs: ReadonlyArray<PullRequest>) {
|
||||
const remotes = await getRemotes(this.repository)
|
||||
const prRemotes = new Set<string>()
|
||||
|
||||
for (const pr of openPRs) {
|
||||
if (pr.head.gitHubRepository.cloneURL !== null) {
|
||||
prRemotes.add(pr.head.gitHubRepository.cloneURL)
|
||||
}
|
||||
}
|
||||
const prRemoteUrls = new Set(
|
||||
openPRs.map(pr => pr.head.gitHubRepository.cloneURL)
|
||||
)
|
||||
const branchRemotes = new Set(this.allBranches.map(branch => branch.remote))
|
||||
|
||||
for (const r of remotes) {
|
||||
if (r.name.startsWith(ForkedRemotePrefix) && !prRemotes.has(r.url)) {
|
||||
if (
|
||||
r.name.startsWith(ForkedRemotePrefix) &&
|
||||
!prRemoteUrls.has(r.url) &&
|
||||
!branchRemotes.has(r.name)
|
||||
) {
|
||||
await removeRemote(this.repository, r.name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue