Skip to content

Commit 4da881b

Browse files
committed
Fix wrong redirect URL after fork, add test
1 parent 64fa570 commit 4da881b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

routers/web/repo/editor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func GetEditRepositoryOrFork(ctx *context.Context, editOperation string) *repo_m
178178
}
179179

180180
// No editable repository, suggest to create a fork
181-
forkToEditFileCommon(ctx, ctx.Repo.TreePath, editOperation, notEditableMessage)
181+
forkToEditFileCommon(ctx, editOperation, ctx.Repo.TreePath, notEditableMessage)
182182
ctx.HTML(http.StatusOK, tplForkFile)
183183
return nil
184184
}
@@ -299,7 +299,7 @@ func ForkToEditFilePost(ctx *context.Context) {
299299
SingleBranch: ctx.Repo.BranchName,
300300
}, tplForkFile, form)
301301
if err != nil {
302-
forkToEditFileCommon(ctx, form.TreePath, form.EditOperation, notEditableMessage)
302+
forkToEditFileCommon(ctx, form.EditOperation, form.TreePath, notEditableMessage)
303303
ctx.HTML(http.StatusOK, tplForkFile)
304304
return
305305
}

tests/integration/editor_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
user_model "code.gitea.io/gitea/models/user"
2121
"code.gitea.io/gitea/modules/git"
2222
"code.gitea.io/gitea/modules/json"
23+
"code.gitea.io/gitea/modules/test"
2324
"code.gitea.io/gitea/modules/translation"
2425
"code.gitea.io/gitea/tests"
2526

@@ -477,7 +478,8 @@ func forkToEdit(t *testing.T, session *TestSession, owner, repo, operation, bran
477478
"edit_operation": operation,
478479
},
479480
)
480-
session.MakeRequest(t, req, http.StatusSeeOther)
481+
resp = session.MakeRequest(t, req, http.StatusSeeOther)
482+
assert.Equal(t, "/"+path.Join(owner, repo, operation, branch, filePath), test.RedirectURL(resp))
481483
}
482484

483485
func testForkToEdit(t *testing.T, session *TestSession, user, owner, repo, branch, filePath string) {

0 commit comments

Comments
 (0)