Skip to content

Commit eb67c4c

Browse files
wxiaoguangjerger
authored andcommitted
Fix some trivial problems (go-gitea#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 ba0deab)
1 parent 875534e commit eb67c4c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

routers/api/packages/swift/swift.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func formFileOptionalReadCloser(ctx *context.Context, formKey string) (io.ReadCl
304304
if content == "" {
305305
return nil, nil
306306
}
307-
return io.NopCloser(strings.NewReader(ctx.Req.FormValue(formKey))), nil
307+
return io.NopCloser(strings.NewReader(content)), nil
308308
}
309309

310310
// UploadPackageFile refers to https://github.com/swiftlang/swift-package-manager/blob/main/Documentation/PackageRegistry/Registry.md#endpoint-6

routers/web/repo/pull.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,23 @@ func setMergeTarget(ctx *context.Context, pull *issues_model.PullRequest) {
401401

402402
// GetPullDiffStats get Pull Requests diff stats
403403
func GetPullDiffStats(ctx *context.Context) {
404+
// FIXME: this getPullInfo seems to be a duplicate call with other route handlers
404405
issue, ok := getPullInfo(ctx)
405406
if !ok {
406407
return
407408
}
408409
pull := issue.PullRequest
409410

410411
mergeBaseCommitID := GetMergedBaseCommitID(ctx, issue)
411-
412412
if mergeBaseCommitID == "" {
413413
ctx.NotFound("PullFiles", nil)
414414
return
415415
}
416416

417+
// do not report 500 server error to end users if error occurs, otherwise a PR missing ref won't be able to view.
417418
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pull.GetGitRefName())
418419
if err != nil {
419-
ctx.ServerError("GetRefCommitID", err)
420+
log.Error("Failed to GetRefCommitID: %v, repo: %v", err, ctx.Repo.Repository.FullName())
420421
return
421422
}
422423

0 commit comments

Comments
 (0)