Skip to content

Commit cad875a

Browse files
committed
repo list: render repo tags into the 3rd column instead of the 2nd
1 parent b7c2865 commit cad875a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

pkg/cmd/repo/list/list.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"net/http"
66
"strings"
77
"time"
8-
"unicode"
98

109
"github.com/cli/cli/api"
1110
"github.com/cli/cli/internal/ghinstance"
@@ -153,13 +152,13 @@ func listRun(opts *ListOptions) error {
153152

154153
if tp.IsTTY() {
155154
tp.AddField(nameWithOwner, nil, cs.Bold)
156-
tp.AddField(info, nil, infoColor)
157155
tp.AddField(text.ReplaceExcessiveWhitespace(description), nil, nil)
156+
tp.AddField(info, nil, infoColor)
158157
tp.AddField(utils.FuzzyAgoAbbr(now, repo.UpdatedAt), nil, nil)
159158
} else {
160159
tp.AddField(nameWithOwner, nil, nil)
161-
tp.AddField(visibility, nil, nil)
162160
tp.AddField(text.ReplaceExcessiveWhitespace(description), nil, nil)
161+
tp.AddField(visibility, nil, nil)
163162
tp.AddField(updatedAt, nil, nil)
164163
}
165164
tp.EndRow()
@@ -196,22 +195,21 @@ type Repository struct {
196195

197196
func (r Repository) Info() string {
198197
var info string
198+
var tags []string
199199

200200
if r.IsPrivate {
201-
info = "private"
201+
tags = append(tags, "private")
202202
}
203203
if r.IsFork {
204-
info += " fork"
204+
tags = append(tags, "fork")
205205
}
206206
if r.IsArchived {
207-
info += " archived"
207+
tags = append(tags, "archived")
208208
}
209209

210-
if info != "" {
211-
info = strings.TrimPrefix(info, " ")
212-
infoRunes := []rune(info)
213-
infoRunes[0] = unicode.ToUpper(infoRunes[0])
214-
info = fmt.Sprintf("(%s)", string(infoRunes))
210+
if len(tags) > 0 {
211+
tags[0] = strings.Title(tags[0])
212+
info = strings.Join(tags, ", ")
215213
}
216214

217215
return info

0 commit comments

Comments
 (0)