mirror of
https://gitea.com/gitea/tea
synced 2024-10-31 21:20:23 +00:00
cbd1bccbf9
Merge branch 'master' into add-repo-search-improve-listing-closes-#210 Merge branch 'master' into add-repo-search-improve-listing-closes-#210 fixup! repos list: client side filtering for repo type fix --private flag repos list: client side filtering for repo type repos list: listing of starred repos repos search: rename --mode to --type repo search: prioritize own user UX tradeoff between usefulness & response speed fix -O owner flag filter rework repo list, add repo search repo search is mostly the old behaviour of repo list Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Norwin Roosen <git@nroo.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/215 Reviewed-by: 6543 <6543@noreply.gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
84 lines
1.4 KiB
Go
84 lines
1.4 KiB
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package print
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
"code.gitea.io/tea/cmd/flags"
|
|
)
|
|
|
|
// ReposList prints a listing of the repos
|
|
func ReposList(rps []*gitea.Repository) {
|
|
if len(rps) == 0 {
|
|
fmt.Println("No repositories found")
|
|
return
|
|
}
|
|
|
|
headers := []string{
|
|
"Name",
|
|
"Type",
|
|
"SSH",
|
|
"Owner",
|
|
}
|
|
var values [][]string
|
|
|
|
for _, rp := range rps {
|
|
var mode = "source"
|
|
if rp.Fork {
|
|
mode = "fork"
|
|
}
|
|
if rp.Mirror {
|
|
mode = "mirror"
|
|
}
|
|
|
|
values = append(
|
|
values,
|
|
[]string{
|
|
rp.FullName,
|
|
mode,
|
|
rp.SSHURL,
|
|
rp.Owner.UserName,
|
|
},
|
|
)
|
|
}
|
|
|
|
OutputList(flags.GlobalOutputValue, headers, values)
|
|
}
|
|
|
|
// RepoDetails print an repo formatted to stdout
|
|
func RepoDetails(repo *gitea.Repository, topics []string) {
|
|
output := repo.FullName
|
|
if repo.Mirror {
|
|
output += " (mirror)"
|
|
}
|
|
if repo.Fork {
|
|
output += " (fork)"
|
|
}
|
|
if repo.Archived {
|
|
output += " (archived)"
|
|
}
|
|
if repo.Empty {
|
|
output += " (empty)"
|
|
}
|
|
output += "\n"
|
|
if len(topics) != 0 {
|
|
output += "Topics: " + strings.Join(topics, ", ") + "\n"
|
|
}
|
|
output += "\n"
|
|
output += repo.Description + "\n\n"
|
|
output += fmt.Sprintf(
|
|
"Open Issues: %d, Stars: %d, Forks: %d, Size: %s\n\n",
|
|
repo.OpenIssues,
|
|
repo.Stars,
|
|
repo.Forks,
|
|
formatSize(int64(repo.Size)),
|
|
)
|
|
|
|
fmt.Print(output)
|
|
}
|