Skip to content

Commit 2410c43

Browse files
committed
Compare repositories by ID, add Gitea copyright to new file
1 parent b51ff01 commit 2410c43

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

routers/web/repo/editor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2016 The Gogs Authors. All rights reserved.
2+
// Copyright 2025 The Gitea Authors. All rights reserved.
23
// SPDX-License-Identifier: MIT
34

45
package repo
@@ -46,7 +47,7 @@ func canCreateBasePullRequest(ctx *context.Context, editRepo *repo_model.Reposit
4647
}
4748

4849
func renderCommitRights(ctx *context.Context, editRepo *repo_model.Repository) bool {
49-
if editRepo == ctx.Repo.Repository {
50+
if editRepo.ID == ctx.Repo.Repository.ID {
5051
// Editing the same repository that we are viewing
5152
canCommitToBranch, err := context.CanCommitToBranch(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.BranchName)
5253
if err != nil {

routers/web/repo/fork_to_edit.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2016 The Gogs Authors. All rights reserved.
2+
// Copyright 2025 The Gitea Authors. All rights reserved.
23
// SPDX-License-Identifier: MIT
34

45
package repo
@@ -111,7 +112,7 @@ func getEditRepositoryOrError(ctx *context.Context, tpl templates.TplName, form
111112
// and if not renders an error and returns false.
112113
func canPushToEditRepository(ctx *context.Context, editRepo *repo_model.Repository, branchName, commitChoice string, tpl templates.TplName, form any) bool {
113114
// When pushing to a fork or chosing to commit to a new branch, it should not exist yet
114-
if ctx.Repo.Repository != editRepo || commitChoice == frmCommitChoiceNewBranch {
115+
if editRepo.ID != ctx.Repo.Repository.ID || commitChoice == frmCommitChoiceNewBranch {
115116
if exist, err := git_model.IsBranchExist(ctx, editRepo.ID, branchName); err == nil && exist {
116117
ctx.Data["Err_NewBranchName"] = true
117118
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchName), tpl, form)
@@ -137,8 +138,8 @@ func canPushToEditRepository(ctx *context.Context, editRepo *repo_model.Reposito
137138
// to the user fork, if needed. On failure, it displays and returns an error. The
138139
// branch name to be used for editing is returned.
139140
func pushToEditRepositoryOrError(ctx *context.Context, editRepo *repo_model.Repository, branchName string, tpl templates.TplName, form any) (string, error) {
140-
// If editing the repository, no need to push anything
141-
if editRepo == ctx.Repo.Repository {
141+
// If editing the same repository, no need to push anything
142+
if editRepo.ID == ctx.Repo.Repository.ID {
142143
return ctx.Repo.BranchName, nil
143144
}
144145

0 commit comments

Comments
 (0)