Skip to content

Commit 16e3600

Browse files
authored
Editor error message misleading due to re-used key. (#29859)
The error message: `editor.file_changed_while_editing = The file contents have changed since you started editing. <a target="_blank" rel="noopener noreferrer" href="%s">Click here</a> to see them or <strong>Commit Changes again</strong> to overwrite them.` Is re-used in inappropriate contexts. The link in the key goes to a 404 when the key is used in a situation where the file contents have not changed. Added two new keys to differentiate commit id mismatch and push out of date conditions.
1 parent a4a766f commit 16e3600

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

options/locale/locale_en-US.ini

+2
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,8 @@ editor.file_editing_no_longer_exists = The file being edited, "%s", no longer ex
13121312
editor.file_deleting_no_longer_exists = The file being deleted, "%s", no longer exists in this repository.
13131313
editor.file_changed_while_editing = The file contents have changed since you started editing. <a target="_blank" rel="noopener noreferrer" href="%s">Click here</a> to see them or <strong>Commit Changes again</strong> to overwrite them.
13141314
editor.file_already_exists = A file named "%s" already exists in this repository.
1315+
editor.commit_id_not_matching = The Commit ID does not match the ID when you began editing. Commit into a patch branch and then merge.
1316+
editor.push_out_of_date = The push appears to be out of date.
13151317
editor.commit_empty_file_header = Commit an empty file
13161318
editor.commit_empty_file_text = The file you're about to commit is empty. Proceed?
13171319
editor.no_changes_to_show = There are no changes to show.

routers/web/repo/editor.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
333333
ctx.Error(http.StatusInternalServerError, err.Error())
334334
}
335335
} else if models.IsErrCommitIDDoesNotMatch(err) {
336-
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(ctx.Repo.CommitID)), tplEditFile, &form)
336+
ctx.RenderWithErr(ctx.Tr("repo.editor.commit_id_not_matching", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(ctx.Repo.CommitID)), tplEditFile, &form)
337337
} else if git.IsErrPushOutOfDate(err) {
338-
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(form.NewBranchName)), tplEditFile, &form)
338+
ctx.RenderWithErr(ctx.Tr("repo.editor.push_out_of_date", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(form.NewBranchName)), tplEditFile, &form)
339339
} else if git.IsErrPushRejected(err) {
340340
errPushRej := err.(*git.ErrPushRejected)
341341
if len(errPushRej.Message) == 0 {

0 commit comments

Comments
 (0)