Commit da18211f authored by Stan Hu's avatar Stan Hu

Fix Error 500 when user commits Wiki page with no commit message

Previously if a user submitted a blank commit message, Gitaly would
error out with `3:WikiWritePage: empty CommitDetails.Message` since
Gitaly checks whether any content is present for the message. We now
use a default commit message if a user leaves it blank.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59065
parent 250f6ad2
...@@ -183,7 +183,7 @@ class ProjectWiki ...@@ -183,7 +183,7 @@ class ProjectWiki
end end
def commit_details(action, message = nil, title = nil) def commit_details(action, message = nil, title = nil)
commit_message = message || default_message(action, title) commit_message = message.presence || default_message(action, title)
git_user = Gitlab::Git::User.from_gitlab(@user) git_user = Gitlab::Git::User.from_gitlab(@user)
Gitlab::Git::Wiki::CommitDetails.new(@user.id, Gitlab::Git::Wiki::CommitDetails.new(@user.id,
......
---
title: Fix Error 500 when user commits Wiki page with no commit message
merge_request: 26247
author:
type: fixed
...@@ -71,6 +71,14 @@ describe ProjectWiki do ...@@ -71,6 +71,14 @@ describe ProjectWiki do
expect(project_wiki.create_page("index", "test content")).to be_truthy expect(project_wiki.create_page("index", "test content")).to be_truthy
end end
it "creates a new wiki repo with a default commit message" do
expect(project_wiki.create_page("index", "test content", :markdown, "")).to be_truthy
page = project_wiki.find_page('index')
expect(page.last_version.message).to eq("#{user.username} created page: index")
end
it "raises CouldNotCreateWikiError if it can't create the wiki repository" do it "raises CouldNotCreateWikiError if it can't create the wiki repository" do
# Create a fresh project which will not have a wiki # Create a fresh project which will not have a wiki
project_wiki = described_class.new(create(:project), user) project_wiki = described_class.new(create(:project), user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment