Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Fix the runs will not be displayed bug when the main branch have no workflows but other branches have (go-gitea#28359)
  [skip ci] Updated translations via Crowdin
  Render PyPi long description as document (go-gitea#28272)
  handle repository.size column being NULL in migration v263 (go-gitea#28336)
  Fix migration panic due to an empty review comment diff (go-gitea#28334)
  Add `HEAD` support for rpm repo files (go-gitea#28309)
  Remove deprecated query condition in ListReleases (go-gitea#28339)
  • Loading branch information
zjjhot committed Dec 6, 2023
2 parents 8fcd936 + 09d5028 commit 0d2c650
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 20 deletions.
7 changes: 6 additions & 1 deletion models/migrations/v1_21/v263.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ func AddGitSizeAndLFSSizeToRepositoryTable(x *xorm.Engine) error {
return err
}

_, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size`)
_, err = sess.Exec(`UPDATE repository SET size = 0 WHERE size IS NULL`)
if err != nil {
return err
}

_, err = sess.Exec(`UPDATE repository SET git_size = size - lfs_size WHERE size > lfs_size`)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions modules/templates/util_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func RenderMarkdownToHtml(ctx context.Context, input string) template.HTML { //n
output, err := markdown.RenderString(&markup.RenderContext{
Ctx: ctx,
URLPrefix: setting.AppSubURL,
Metas: map[string]string{"mode": "document"},
}, input)
if err != nil {
log.Error("RenderString: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3305,7 +3305,7 @@ error.unit_not_allowed=Não tem permissão para aceder a esta parte do repositó
title=Pacotes
desc=Gerir pacotes do repositório.
empty=Ainda não há pacotes.
empty.documentation=Para obter mais informação sobre o registo de pacotes, veja <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/packages/overview/">a documentação</a>.
empty.documentation=Para obter mais informação sobre o registo de pacotes, veja <a target="_blank" rel="noopener noreferrer" href="%s">a documentação</a>.
empty.repo=Carregou um pacote mas este não é apresentado aqui? Vá às <a href="%[1]s">configurações do pacote</a> e ligue-o a este repositório.
registry.documentation=Para mais informação sobre o registo %s, veja <a target="_blank" rel="noopener noreferrer" href="%s">a documentação</a>.
filter.type=Tipo
Expand Down
5 changes: 4 additions & 1 deletion routers/api/packages/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,10 @@ func CommonRoutes() *web.Route {
r.Get("", rpm.DownloadPackageFile)
r.Delete("", reqPackageAccess(perm.AccessModeWrite), rpm.DeletePackageFile)
})
r.Get("/repodata/{filename}", rpm.GetRepositoryFile)
r.Group("/repodata/{filename}", func() {
r.Head("", rpm.CheckRepositoryFileExistence)
r.Get("", rpm.GetRepositoryFile)
})
}, reqPackageAccess(perm.AccessModeRead))
r.Group("/rubygems", func() {
r.Get("/specs.4.8.gz", rubygems.EnumeratePackages)
Expand Down
24 changes: 24 additions & 0 deletions routers/api/packages/rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@ func GetRepositoryKey(ctx *context.Context) {
})
}

func CheckRepositoryFileExistence(ctx *context.Context) {
pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}

pf, err := packages_model.GetFileForVersionByName(ctx, pv.ID, ctx.Params("filename"), packages_model.EmptyFileKey)
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.Status(http.StatusNotFound)
} else {
apiError(ctx, http.StatusInternalServerError, err)
}
return
}

ctx.SetServeHeaders(&context.ServeHeaderOptions{
Filename: pf.Name,
LastModified: pf.CreatedUnix.AsLocalTime(),
})
ctx.Status(http.StatusOK)
}

// Gets a pre-generated repository metadata file
func GetRepositoryFile(ctx *context.Context) {
pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
Expand Down
8 changes: 0 additions & 8 deletions routers/api/v1/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ func ListReleases(ctx *context.APIContext) {
// in: query
// description: filter (exclude / include) pre-releases
// type: boolean
// - name: per_page
// in: query
// description: page size of results, deprecated - use limit
// type: integer
// deprecated: true
// - name: page
// in: query
// description: page number of results to return (1-based)
Expand All @@ -152,9 +147,6 @@ func ListReleases(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
listOptions := utils.GetListOptions(ctx)
if listOptions.PageSize == 0 && ctx.FormInt("per_page") != 0 {
listOptions.PageSize = ctx.FormInt("per_page")
}

opts := repo_model.FindReleasesOptions{
ListOptions: listOptions,
Expand Down
1 change: 1 addition & 0 deletions routers/web/repo/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func List(ctx *context.Context) {
pager.AddParamString("actor", fmt.Sprint(actorID))
pager.AddParamString("status", fmt.Sprint(status))
ctx.Data["Page"] = pager
ctx.Data["HasWorkflowsOrRuns"] = len(workflows) > 0 || len(runs) > 0

ctx.HTML(http.StatusOK, tplListActions)
}
2 changes: 1 addition & 1 deletion services/migrations/gitea_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
line := comment.Line
if line != 0 {
comment.Position = 1
} else {
} else if comment.DiffHunk != "" {
_, _, line, _ = git.ParseDiffHunkString(comment.DiffHunk)
}

Expand Down
2 changes: 1 addition & 1 deletion templates/repo/actions/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="ui container">
{{template "base/alert" .}}

{{if .workflows}}
{{if .HasWorkflowsOrRuns}}
<div class="ui stackable grid">
<div class="four wide column">
<div class="ui fluid vertical menu">
Expand Down
6 changes: 0 additions & 6 deletions templates/swagger/v1_json.tmpl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion tests/integration/api_packages_rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,18 @@ gpgkey=%sapi/packages/%s/rpm/repository.key`, user.Name, user.Name, setting.AppN

url := rootURL + "/repodata"

req := NewRequest(t, "GET", url+"/dummy.xml")
req := NewRequest(t, "HEAD", url+"/dummy.xml")
MakeRequest(t, req, http.StatusNotFound)

req = NewRequest(t, "GET", url+"/dummy.xml")
MakeRequest(t, req, http.StatusNotFound)

t.Run("repomd.xml", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()

req = NewRequest(t, "HEAD", url+"/repomd.xml")
MakeRequest(t, req, http.StatusOK)

req = NewRequest(t, "GET", url+"/repomd.xml")
resp := MakeRequest(t, req, http.StatusOK)

Expand Down

0 comments on commit 0d2c650

Please sign in to comment.