Compare commits

..

No commits in common. "151b1a9508d9a407163edbf3d726b4785afef5ce" and "7ddc11def7e524df194cd67a93cf83cf733b1b79" have entirely different histories.

16 changed files with 18 additions and 84 deletions

View File

@ -175,15 +175,6 @@ func (t CommentType) String() string {
return commentStrings[t]
}
func AsCommentType(typeName string) CommentType {
for index, name := range commentStrings {
if typeName == name {
return CommentType(index)
}
}
return CommentTypeUnknown
}
// RoleDescriptor defines comment tag type
type RoleDescriptor int

View File

@ -62,10 +62,3 @@ func TestFetchCodeComments(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, res, 1)
}
func TestAsCommentType(t *testing.T) {
assert.Equal(t, issues_model.CommentTypeUnknown, issues_model.AsCommentType(""))
assert.Equal(t, issues_model.CommentTypeUnknown, issues_model.AsCommentType("nonsense"))
assert.Equal(t, issues_model.CommentTypeComment, issues_model.AsCommentType("comment"))
assert.Equal(t, issues_model.CommentTypePRUnScheduledToAutoMerge, issues_model.AsCommentType("pull_cancel_scheduled_merge"))
}

View File

@ -85,16 +85,7 @@ func DeleteBlobByID(ctx context.Context, blobID int64) error {
}
// GetTotalBlobSize returns the total blobs size in bytes
func GetTotalBlobSize(ctx context.Context) (int64, error) {
return db.GetEngine(ctx).
SumInt(&PackageBlob{}, "size")
}
// GetTotalUnreferencedBlobSize returns the total size of all unreferenced blobs in bytes
func GetTotalUnreferencedBlobSize(ctx context.Context) (int64, error) {
return db.GetEngine(ctx).
Table("package_blob").
Join("LEFT", "package_file", "package_file.blob_id = package_blob.id").
Where("package_file.id IS NULL").
func GetTotalBlobSize() (int64, error) {
return db.GetEngine(db.DefaultContext).
SumInt(&PackageBlob{}, "size")
}

View File

@ -199,9 +199,9 @@ func SearchFiles(ctx context.Context, opts *PackageFileSearchOptions) ([]*Packag
return pfs, count, err
}
// CalculateFileSize sums up all blob sizes matching the search options.
// CalculateBlobSize sums up all blob sizes matching the search options.
// It does NOT respect the deduplication of blobs.
func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int64, error) {
func CalculateBlobSize(ctx context.Context, opts *PackageFileSearchOptions) (int64, error) {
return db.GetEngine(ctx).
Table("package_file").
Where(opts.toConds()).

View File

@ -1233,10 +1233,7 @@ func GetUserByOpenID(uri string) (*User, error) {
// GetAdminUser returns the first administrator
func GetAdminUser() (*User, error) {
var admin User
has, err := db.GetEngine(db.DefaultContext).
Where("is_admin=?", true).
Asc("id"). // Reliably get the admin with the lowest ID.
Get(&admin)
has, err := db.GetEngine(db.DefaultContext).Where("is_admin=?", true).Get(&admin)
if err != nil {
return nil, err
} else if !has {

View File

@ -17,7 +17,6 @@ type Commentable interface {
type Comment struct {
IssueIndex int64 `yaml:"issue_index"`
Index int64
CommentType string `yaml:"comment_type"` // see `commentStrings` in models/issues/comment.go
PosterID int64 `yaml:"poster_id"`
PosterName string `yaml:"poster_name"`
PosterEmail string `yaml:"poster_email"`
@ -25,7 +24,6 @@ type Comment struct {
Updated time.Time
Content string
Reactions []*Reaction
Meta map[string]interface{} `yaml:"meta,omitempty"` // see models/issues/comment.go for fields in Comment struct
}
// GetExternalName ExternalUserMigrated interface

View File

@ -2645,7 +2645,6 @@ repos.size = Size
packages.package_manage_panel = Package Management
packages.total_size = Total Size: %s
packages.unreferenced_size = Unreferenced Size: %s
packages.owner = Owner
packages.creator = Creator
packages.name = Name

View File

@ -51,18 +51,12 @@ func Packages(ctx *context.Context) {
return
}
totalBlobSize, err := packages_model.GetTotalBlobSize(ctx)
totalBlobSize, err := packages_model.GetTotalBlobSize()
if err != nil {
ctx.ServerError("GetTotalBlobSize", err)
return
}
totalUnreferencedBlobSize, err := packages_model.GetTotalUnreferencedBlobSize(ctx)
if err != nil {
ctx.ServerError("CalculateBlobSize", err)
return
}
ctx.Data["Title"] = ctx.Tr("packages.title")
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminPackages"] = true
@ -71,9 +65,8 @@ func Packages(ctx *context.Context) {
ctx.Data["AvailableTypes"] = packages_model.TypeList
ctx.Data["SortType"] = sort
ctx.Data["PackageDescriptors"] = pds
ctx.Data["TotalCount"] = total
ctx.Data["TotalBlobSize"] = totalBlobSize - totalUnreferencedBlobSize
ctx.Data["TotalUnreferencedBlobSize"] = totalUnreferencedBlobSize
ctx.Data["Total"] = total
ctx.Data["TotalBlobSize"] = totalBlobSize
pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
pager.AddParamString("q", query)

View File

@ -784,8 +784,7 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
}
}
if template.Ref != "" && !strings.HasPrefix(template.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
if !strings.HasPrefix(template.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
template.Ref = git.BranchPrefix + template.Ref
}
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0

View File

@ -18,7 +18,6 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/references"
"code.gitea.io/gitea/modules/repository"
@ -176,8 +175,7 @@ func UpdateIssuesCommit(doer *user_model.User, repo *repo_model.Repository, comm
if !repo.CloseIssuesViaCommitInAnyBranch {
// If the issue was specified to be in a particular branch, don't allow commits in other branches to close it
if refIssue.Ref != "" {
issueBranchName := strings.TrimPrefix(refIssue.Ref, git.BranchPrefix)
if branchName != issueBranchName {
if branchName != refIssue.Ref {
continue
}
// Otherwise, only process commits to the default branch

View File

@ -454,34 +454,15 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
if comment.Updated.IsZero() {
comment.Updated = comment.Created
}
if comment.CommentType == "" {
// if type field is missing, then assume a normal comment
comment.CommentType = issues_model.CommentTypeComment.String()
}
cm := issues_model.Comment{
IssueID: issue.ID,
Type: issues_model.AsCommentType(comment.CommentType),
Type: issues_model.CommentTypeComment,
Content: comment.Content,
CreatedUnix: timeutil.TimeStamp(comment.Created.Unix()),
UpdatedUnix: timeutil.TimeStamp(comment.Updated.Unix()),
}
switch cm.Type {
case issues_model.CommentTypeAssignees:
cm.AssigneeID = comment.Meta["AssigneeID"].(int64)
if comment.Meta["RemovedAssigneeID"] != nil {
cm.RemovedAssignee = true
}
case issues_model.CommentTypeChangeTitle:
if comment.Meta["OldTitle"] != nil {
cm.OldTitle = fmt.Sprintf("%s", comment.Meta["OldTitle"])
}
if comment.Meta["NewTitle"] != nil {
cm.NewTitle = fmt.Sprintf("%s", comment.Meta["NewTitle"])
}
default:
}
if err := g.remapUser(comment, &cm); err != nil {
return err
}

View File

@ -361,11 +361,11 @@ func checkSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, p
}
if setting.Packages.LimitTotalOwnerSize > -1 {
totalSize, err := packages_model.CalculateFileSize(ctx, &packages_model.PackageFileSearchOptions{
totalSize, err := packages_model.CalculateBlobSize(ctx, &packages_model.PackageFileSearchOptions{
OwnerID: owner.ID,
})
if err != nil {
log.Error("CalculateFileSize failed: %v", err)
log.Error("CalculateBlobSize failed: %v", err)
return err
}
if totalSize+uploadSize > setting.Packages.LimitTotalOwnerSize {

View File

@ -118,9 +118,6 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
}
prUnit, err := pr.BaseRepo.GetUnit(ctx, unit.TypePullRequests)
if err != nil {
if repo_model.IsErrUnitTypeNotExist(err) {
return false, false, nil
}
log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err)
return false, false, err
}

View File

@ -4,9 +4,7 @@
<div class="ui container">
{{template "base/alert" .}}
<h4 class="ui top attached header">
{{.locale.Tr "admin.packages.package_manage_panel"}} ({{.locale.Tr "admin.total" .TotalCount}},
{{.locale.Tr "admin.packages.total_size" (FileSize .TotalBlobSize)}},
{{.locale.Tr "admin.packages.unreferenced_size" (FileSize .TotalUnreferencedBlobSize)}})
{{.locale.Tr "admin.packages.package_manage_panel"}} ({{.locale.Tr "admin.total" .Total}}, {{.locale.Tr "admin.packages.total_size" (FileSize .TotalBlobSize)}})
</h4>
<div class="ui attached segment">
<form class="ui form ignore-dirty">

View File

@ -2,10 +2,7 @@ export async function renderAsciinemaPlayer() {
const els = document.querySelectorAll('.asciinema-player-container');
if (!els.length) return;
const [player] = await Promise.all([
import(/* webpackChunkName: "asciinema-player" */'asciinema-player'),
import(/* webpackChunkName: "asciinema-player" */'asciinema-player/dist/bundle/asciinema-player.css'),
]);
const player = await import(/* webpackChunkName: "asciinema-player" */'asciinema-player');
for (const el of els) {
player.create(el.getAttribute('data-asciinema-player-src'), el, {

View File

@ -1,3 +1,5 @@
@import "../asciinema-player/dist/bundle/asciinema-player.css";
.asciinema-player-container {
width: 100%;
height: auto;