mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-27 04:07:08 +00:00
Merge branch 'forgejo' into forgejo-federated-star
This commit is contained in:
commit
af0d0f7745
1797 changed files with 43301 additions and 68933 deletions
|
@ -16,13 +16,14 @@ import (
|
|||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/optional"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/translation"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"xorm.io/builder"
|
||||
|
@ -235,6 +236,7 @@ type SizeDetail struct {
|
|||
}
|
||||
|
||||
// SizeDetails forms a struct with various size details about repository
|
||||
// Note: SizeDetailsString below expects it to have 2 entries
|
||||
func (repo *Repository) SizeDetails() []SizeDetail {
|
||||
sizeDetails := []SizeDetail{
|
||||
{
|
||||
|
@ -250,13 +252,9 @@ func (repo *Repository) SizeDetails() []SizeDetail {
|
|||
}
|
||||
|
||||
// SizeDetailsString returns a concatenation of all repository size details as a string
|
||||
func (repo *Repository) SizeDetailsString() string {
|
||||
var str strings.Builder
|
||||
func (repo *Repository) SizeDetailsString(locale translation.Locale) string {
|
||||
sizeDetails := repo.SizeDetails()
|
||||
for _, detail := range sizeDetails {
|
||||
str.WriteString(fmt.Sprintf("%s: %s, ", detail.Name, base.FileSize(detail.Size)))
|
||||
}
|
||||
return strings.TrimSuffix(str.String(), ", ")
|
||||
return locale.TrString("repo.size_format", sizeDetails[0].Name, locale.TrSize(sizeDetails[0].Size), sizeDetails[1].Name, locale.TrSize(sizeDetails[1].Size))
|
||||
}
|
||||
|
||||
func (repo *Repository) LogString() string {
|
||||
|
@ -562,6 +560,9 @@ func (repo *Repository) GetBaseRepo(ctx context.Context) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
if repo.BaseRepo != nil {
|
||||
return nil
|
||||
}
|
||||
repo.BaseRepo, err = GetRepositoryByID(ctx, repo.ForkID)
|
||||
return err
|
||||
}
|
||||
|
@ -883,7 +884,7 @@ func (repo *Repository) TemplateRepo(ctx context.Context) *Repository {
|
|||
|
||||
type CountRepositoryOptions struct {
|
||||
OwnerID int64
|
||||
Private util.OptionalBool
|
||||
Private optional.Option[bool]
|
||||
}
|
||||
|
||||
// CountRepositories returns number of repositories.
|
||||
|
@ -895,8 +896,8 @@ func CountRepositories(ctx context.Context, opts CountRepositoryOptions) (int64,
|
|||
if opts.OwnerID > 0 {
|
||||
sess.And("owner_id = ?", opts.OwnerID)
|
||||
}
|
||||
if !opts.Private.IsNone() {
|
||||
sess.And("is_private=?", opts.Private.IsTrue())
|
||||
if opts.Private.Has() {
|
||||
sess.And("is_private=?", opts.Private.Value())
|
||||
}
|
||||
|
||||
count, err := sess.Count(new(Repository))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue