gh pr create duplicates targets if there are duplicate remotes (#8184)
* `gh pr create` duplicates targets if there are duplicate remotes * De-duplicate the same remote
This commit is contained in:
parent
5916439d22
commit
fd8bbf0be5
1 changed files with 4 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ package context
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"sort"
|
||||
|
||||
"github.com/cli/cli/v2/api"
|
||||
|
|
@ -116,9 +117,11 @@ func (r *ResolvedRemotes) HeadRepos() ([]*api.Repository, error) {
|
|||
}
|
||||
|
||||
var results []*api.Repository
|
||||
var ids []string // Check if repo duplicates
|
||||
for _, repo := range r.network.Repositories {
|
||||
if repo != nil && repo.ViewerCanPush() {
|
||||
if repo != nil && repo.ViewerCanPush() && !slices.Contains(ids, repo.ID) {
|
||||
results = append(results, repo)
|
||||
ids = append(ids, repo.ID)
|
||||
}
|
||||
}
|
||||
return results, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue