Skip to content

Commit c92d8e5

Browse files
committed
Merge branch 'release/v1.21' into blender-merged-develop
2 parents 9517fd7 + b56a9f6 commit c92d8e5

File tree

25 files changed

+81
-50
lines changed

25 files changed

+81
-50
lines changed

models/migrations/v1_21/v263.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ func AddGitSizeAndLFSSizeToRepositoryTable(x *xorm.Engine) error {
3232
return err
3333
}
3434

35-
_, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size`)
35+
_, err = sess.Exec(`UPDATE repository SET size = 0 WHERE size IS NULL`)
36+
if err != nil {
37+
return err
38+
}
39+
40+
_, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size WHERE size > lfs_size`)
3641
if err != nil {
3742
return err
3843
}

modules/git/commit.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ func (c *Commit) Message() string {
4343
}
4444

4545
// Summary returns first line of commit message.
46+
// The string is forced to be valid UTF8
4647
func (c *Commit) Summary() string {
47-
return strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0]
48+
return strings.ToValidUTF8(strings.Split(strings.TrimSpace(c.CommitMessage), "\n")[0], "?")
4849
}
4950

5051
// ParentID returns oid of n-th parent (0-based index).

modules/setting/attachment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func loadAttachmentFrom(rootCfg ConfigProvider) (err error) {
2626
}
2727

2828
Attachment.AllowedTypes = sec.Key("ALLOWED_TYPES").MustString(".csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip")
29-
Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(4)
29+
Attachment.MaxSize = sec.Key("MAX_SIZE").MustInt64(2048)
3030
Attachment.MaxFiles = sec.Key("MAX_FILES").MustInt(5)
3131
Attachment.Enabled = sec.Key("ENABLED").MustBool(true)
3232

modules/setting/database.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"net"
1010
"net/url"
1111
"os"
12-
"path"
1312
"path/filepath"
1413
"strings"
1514
"time"
@@ -117,7 +116,7 @@ func DBConnStr() (string, error) {
117116
if !EnableSQLite3 {
118117
return "", errors.New("this Gitea binary was not built with SQLite3 support")
119118
}
120-
if err := os.MkdirAll(path.Dir(Database.Path), os.ModePerm); err != nil {
119+
if err := os.MkdirAll(filepath.Dir(Database.Path), os.ModePerm); err != nil {
121120
return "", fmt.Errorf("Failed to create directories: %w", err)
122121
}
123122
journalMode := ""

routers/api/packages/api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,10 @@ func CommonRoutes() *web.Route {
520520
r.Get("", rpm.DownloadPackageFile)
521521
r.Delete("", reqPackageAccess(perm.AccessModeWrite), rpm.DeletePackageFile)
522522
})
523-
r.Get("/repodata/{filename}", rpm.GetRepositoryFile)
523+
r.Group("/repodata/{filename}", func() {
524+
r.Head("", rpm.CheckRepositoryFileExistence)
525+
r.Get("", rpm.GetRepositoryFile)
526+
})
524527
}, reqPackageAccess(perm.AccessModeRead))
525528
r.Group("/rubygems", func() {
526529
r.Get("/specs.4.8.gz", rubygems.EnumeratePackages)

routers/api/packages/rpm/rpm.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ func GetRepositoryKey(ctx *context.Context) {
5757
})
5858
}
5959

60+
func CheckRepositoryFileExistence(ctx *context.Context) {
61+
pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
62+
if err != nil {
63+
apiError(ctx, http.StatusInternalServerError, err)
64+
return
65+
}
66+
67+
pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), packages_model.EmptyFileKey)
68+
if err != nil {
69+
if errors.Is(err, util.ErrNotExist) {
70+
ctx.Status(http.StatusNotFound)
71+
} else {
72+
apiError(ctx, http.StatusInternalServerError, err)
73+
}
74+
return
75+
}
76+
77+
ctx.SetServeHeaders(&context.ServeHeaderOptions{
78+
Filename: pf.Name,
79+
LastModified: pf.CreatedUnix.AsLocalTime(),
80+
})
81+
ctx.Status(http.StatusOK)
82+
}
83+
6084
// Gets a pre-generated repository metadata file
6185
func GetRepositoryFile(ctx *context.Context) {
6286
pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)

routers/web/repo/actions/actions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ func List(ctx *context.Context) {
201201
pager.AddParamString("actor", fmt.Sprint(actorID))
202202
pager.AddParamString("status", fmt.Sprint(status))
203203
ctx.Data["Page"] = pager
204+
ctx.Data["HasWorkflowsOrRuns"] = len(workflows) > 0 || len(runs) > 0
204205

205206
ctx.HTML(http.StatusOK, tplListActions)
206207
}

routers/web/repo/view.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -702,21 +702,14 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
702702
}
703703
for _, entry := range allEntries {
704704
if entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib" {
705-
ctx.Data["CitiationExist"] = true
706705
// Read Citation file contents
707-
blob := entry.Blob()
708-
dataRc, err := blob.DataAsync()
709-
if err != nil {
710-
ctx.ServerError("DataAsync", err)
711-
return
712-
}
713-
defer dataRc.Close()
714-
ctx.PageData["citationFileContent"], err = blob.GetBlobContent(setting.UI.MaxDisplayFileSize)
715-
if err != nil {
716-
ctx.ServerError("GetBlobContent", err)
717-
return
706+
if content, err := entry.Blob().GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
707+
log.Error("checkCitationFile: GetBlobContent: %v", err)
708+
} else {
709+
ctx.Data["CitiationExist"] = true
710+
ctx.PageData["citationFileContent"] = content
711+
break
718712
}
719-
break
720713
}
721714
}
722715
}

services/migrations/gitea_uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
862862
line := comment.Line
863863
if line != 0 {
864864
comment.Position = 1
865-
} else {
865+
} else if comment.DiffHunk != "" {
866866
_, _, line, _ = git.ParseDiffHunkString(comment.DiffHunk)
867867
}
868868

services/packages/debian/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func GetOrCreateKeyPair(ctx context.Context, ownerID int64) (string, string, err
6767
}
6868

6969
func generateKeypair() (string, string, error) {
70-
e, err := openpgp.NewEntity(setting.AppName, "Debian Registry", "", nil)
70+
e, err := openpgp.NewEntity("", "Debian Registry", "", nil)
7171
if err != nil {
7272
return "", "", err
7373
}

0 commit comments

Comments
 (0)