Fixes #7152 - Allow create/update/delete message to be empty, use default message (#7324)

* Fixes #7152 - Allow create/update/delete message to be empty, use default message

* Linting fix

* Fix to delete integration tests
This commit is contained in:
Richard Mahn 2019-06-29 11:19:24 -04:00 committed by zeripath
parent 462284e2f5
commit 002b597c1f
7 changed files with 104 additions and 27 deletions

View file

@ -204,6 +204,11 @@ func CreateFile(ctx *context.APIContext, apiOpts api.CreateFileOptions) {
Email: apiOpts.Author.Email,
},
}
if opts.Message == "" {
opts.Message = ctx.Tr("repo.editor.add", opts.TreePath)
}
if fileResponse, err := createOrUpdateFile(ctx, opts); err != nil {
ctx.Error(http.StatusInternalServerError, "CreateFile", err)
} else {
@ -264,6 +269,10 @@ func UpdateFile(ctx *context.APIContext, apiOpts api.UpdateFileOptions) {
},
}
if opts.Message == "" {
opts.Message = ctx.Tr("repo.editor.update", opts.TreePath)
}
if fileResponse, err := createOrUpdateFile(ctx, opts); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateFile", err)
} else {
@ -346,6 +355,10 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) {
},
}
if opts.Message == "" {
opts.Message = ctx.Tr("repo.editor.delete", opts.TreePath)
}
if fileResponse, err := repofiles.DeleteRepoFile(ctx.Repo.Repository, ctx.User, opts); err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteFile", err)
} else {