summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-16 21:30:30 -0700
committerStan Hu <stanhu@gmail.com>2019-03-16 21:32:22 -0700
commitda18211fec5ecb9581a5075d22adec743bb9f901 (patch)
treed74591eed9e488f81de205627eccbad18492a32e
parent250f6ad27963c311e757392b886397c930d6918a (diff)
downloadgitlab-ce-da18211fec5ecb9581a5075d22adec743bb9f901.tar.gz
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
-rw-r--r--app/models/project_wiki.rb2
-rw-r--r--changelogs/unreleased/sh-fix-issue-59065.yml5
-rw-r--r--spec/models/project_wiki_spec.rb8
3 files changed, 14 insertions, 1 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index c43bd45a62f..6ea0716c192 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -183,7 +183,7 @@ class ProjectWiki
end
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)
Gitlab::Git::Wiki::CommitDetails.new(@user.id,
diff --git a/changelogs/unreleased/sh-fix-issue-59065.yml b/changelogs/unreleased/sh-fix-issue-59065.yml
new file mode 100644
index 00000000000..41cd5ce0960
--- /dev/null
+++ b/changelogs/unreleased/sh-fix-issue-59065.yml
@@ -0,0 +1,5 @@
+---
+title: Fix Error 500 when user commits Wiki page with no commit message
+merge_request: 26247
+author:
+type: fixed
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index 3ccc706edf2..7be8d67ba9e 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -71,6 +71,14 @@ describe ProjectWiki do
expect(project_wiki.create_page("index", "test content")).to be_truthy
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
# Create a fresh project which will not have a wiki
project_wiki = described_class.new(create(:project), user)