Fix some trivial problems (#34237)

1. Using existing "content" variable in `swift.go`
2. Do not report 500 server error in `GetPullDiffStats` middleware,
otherwise a PR missing ref won't be able to view.
3. Fix the abused "label button" when listing commits, there was too
much padding space, see the screenshot below.

(cherry picked from commit ba0deab6167236db89c975123570089452776599)
This commit is contained in:
wxiaoguang 2025-04-18 22:56:50 +08:00 committed by Michael Jerger
parent 875534e50a
commit eb67c4c109
2 changed files with 4 additions and 3 deletions

View file

@ -304,7 +304,7 @@ func formFileOptionalReadCloser(ctx *context.Context, formKey string) (io.ReadCl
if content == "" { if content == "" {
return nil, nil return nil, nil
} }
return io.NopCloser(strings.NewReader(ctx.Req.FormValue(formKey))), nil return io.NopCloser(strings.NewReader(content)), nil
} }
// UploadPackageFile refers to https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6 // UploadPackageFile refers to https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6

View file

@ -401,6 +401,7 @@ func setMergeTarget(ctx *context.Context, pull *issues_model.PullRequest) {
// GetPullDiffStats get Pull Requests diff stats // GetPullDiffStats get Pull Requests diff stats
func GetPullDiffStats(ctx *context.Context) { func GetPullDiffStats(ctx *context.Context) {
// FIXME: this getPullInfo seems to be a duplicate call with other route handlers
issue, ok := getPullInfo(ctx) issue, ok := getPullInfo(ctx)
if !ok { if !ok {
return return
@ -408,15 +409,15 @@ func GetPullDiffStats(ctx *context.Context) {
pull := issue.PullRequest pull := issue.PullRequest
mergeBaseCommitID := GetMergedBaseCommitID(ctx, issue) mergeBaseCommitID := GetMergedBaseCommitID(ctx, issue)
if mergeBaseCommitID == "" { if mergeBaseCommitID == "" {
ctx.NotFound("PullFiles", nil) ctx.NotFound("PullFiles", nil)
return return
} }
// do not report 500 server error to end users if error occurs, otherwise a PR missing ref won't be able to view.
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitRefName()) headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitRefName())
if err != nil { if err != nil {
ctx.ServerError("GetRefCommitID", err) log.Error("Failed to GetRefCommitID: %v, repo: %v", err, ctx.Repo.Repository.FullName())
return return
} }