Skip to content

Commit

Permalink
Fix repo menu order
Browse files Browse the repository at this point in the history
  • Loading branch information
Toby Padilla committed Oct 12, 2021
1 parent 13ed89b commit a5cc766
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions internal/tui/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,36 @@ func (b *Bubble) setupCmd() tea.Msg {

func (b *Bubble) menuEntriesFromSource() ([]MenuEntry, error) {
mes := make([]MenuEntry, 0)
rs := b.config.Source.AllRepos()
OUTER:
for _, r := range rs {
acc := b.config.AuthRepo(r.Name, b.session.PublicKey())
if acc == gm.NoAccess && r.Name != "config" {
for _, cr := range b.config.Repos {
acc := b.config.AuthRepo(cr.Repo, b.session.PublicKey())
if acc == gm.NoAccess && cr.Repo != "config" {
continue
}
for _, cr := range b.config.Repos {
if r.Name == cr.Repo {
me, err := b.newMenuEntry(cr.Name, cr.Repo)
if err != nil {
return nil, err
}
mes = append(mes, me)
continue OUTER
}
}
me, err := b.newMenuEntry(r.Name, r.Name)
me, err := b.newMenuEntry(cr.Name, cr.Repo)
if err != nil {
return nil, err
}
mes = append(mes, me)
}
for _, r := range b.config.Source.AllRepos() {
var found bool
for _, me := range mes {
if me.Repo == r.Name {
found = true
}
}
if !found {
acc := b.config.AuthRepo(r.Name, b.session.PublicKey())
if acc == gm.NoAccess {
continue
}
me, err := b.newMenuEntry(r.Name, r.Name)
if err != nil {
return nil, err
}
mes = append(mes, me)
}
}
return mes, nil
}

Expand Down

0 comments on commit a5cc766

Please sign in to comment.