Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2021-05-20 19:32:19 +0300
committerFrancisco Javier López <fjlopez@gitlab.com>2021-05-20 19:32:19 +0300
commit9326ffe8844a38143f396591ae8b8b6698750c4c (patch)
tree5b555e6bd40137c72dc9828f771b1e1789cc3cec
parent5b01e449330898e10f155fa2693a00cfd4ffe26d (diff)
-rw-r--r--ruby/lib/gitaly_server/wiki_service.rb11
-rw-r--r--ruby/lib/gitlab/git/wiki.rb34
2 files changed, 17 insertions, 28 deletions
diff --git a/ruby/lib/gitaly_server/wiki_service.rb b/ruby/lib/gitaly_server/wiki_service.rb
index 6b7d031a5..2e8486044 100644
--- a/ruby/lib/gitaly_server/wiki_service.rb
+++ b/ruby/lib/gitaly_server/wiki_service.rb
@@ -24,17 +24,15 @@ module GitalyServer
format = request.format
commit_details = request.commit_details
ref = set_utf8!(request.ref)
- puts "!!!!!!!!"
- puts request.inspect
end
content << request.content
end
- wiki = Gitlab::Git::Wiki.new(repo)
+ wiki = Gitlab::Git::Wiki.new(repo, ref)
commit_details = commit_details_from_gitaly(commit_details)
- wiki.write_page(name, format.to_sym, ref, content, commit_details)
+ wiki.write_page(name, format.to_sym, content, commit_details)
Gitaly::WikiWritePageResponse.new
rescue Gitlab::Git::Wiki::DuplicatePageError => e
@@ -138,11 +136,10 @@ module GitalyServer
call.each_remote_read.with_index do |request, index|
if index.zero?
repo = Gitlab::Git::Repository.from_gitaly(request.repository, call)
- wiki = Gitlab::Git::Wiki.new(repo)
+ wiki = Gitlab::Git::Wiki.new(repo, set_utf8!(request.ref))
title = set_utf8!(request.title)
page_path = set_utf8!(request.page_path)
format = request.format
- ref = set_utf8!(request.ref)
commit_details = commit_details_from_gitaly(request.commit_details)
end
@@ -150,7 +147,7 @@ module GitalyServer
content << request.content
end
- wiki.update_page(page_path, title, format.to_sym, ref, content, commit_details)
+ wiki.update_page(page_path, title, format.to_sym, content, commit_details)
Gitaly::WikiUpdatePageResponse.new
end
diff --git a/ruby/lib/gitlab/git/wiki.rb b/ruby/lib/gitlab/git/wiki.rb
index 34aade06e..5314aa6f5 100644
--- a/ruby/lib/gitlab/git/wiki.rb
+++ b/ruby/lib/gitlab/git/wiki.rb
@@ -19,27 +19,25 @@ module Gitlab
end
# Initialize with a Gitlab::Git::Repository instance
- def initialize(repository)
+ def initialize(repository, ref = 'master')
@repository = repository
+ @ref = ref
end
def repository_exists?
@repository.exists?
end
- def write_page(name, format, ref, content, commit_details)
- puts "###########"
- puts ref
- puts "##########"
- gollum_write_page(name, format, ref, content, commit_details)
+ def write_page(name, format, content, commit_details)
+ gollum_write_page(name, format, content, commit_details)
end
def delete_page(page_path, commit_details)
gollum_delete_page(page_path, commit_details)
end
- def update_page(page_path, title, format, ref, content, commit_details)
- gollum_update_page(page_path, title, format, ref, content, commit_details)
+ def update_page(page_path, title, format, content, commit_details)
+ gollum_update_page(page_path, title, format, content, commit_details)
end
def pages(limit: nil, sort: nil, direction_desc: false)
@@ -66,13 +64,8 @@ module Gitlab
page.url_path
end
- def gollum_wiki(ref = nil)
- options = {}
- options[:ref] = ref if ref
- puts "*************"
- puts ref
- puts "********"
- @gollum_wiki ||= Gollum::Wiki.new(@repository.path, ref: 'main')
+ def gollum_wiki
+ @gollum_wiki ||= Gollum::Wiki.new(@repository.path, ref: @ref)
end
private
@@ -131,7 +124,7 @@ module Gitlab
gollum_wiki.paged(page_name, page_dir) || (raise PageNotFound, page_path)
end
- def gollum_write_page(name, format, ref, content, commit_details)
+ def gollum_write_page(name, format, content, commit_details)
assert_type!(format, Symbol)
assert_type!(commit_details, CommitDetails)
@@ -139,7 +132,7 @@ module Gitlab
filename = File.basename(name)
dir = (tmp_dir = File.dirname(name)) == '.' ? '' : tmp_dir
- gollum_wiki(ref).write_page(filename, format, content, { committer: committer }, dir)
+ gollum_wiki.write_page(filename, format, content, { committer: committer }, dir)
end
rescue Gollum::DuplicatePageError => e
raise Gitlab::Git::Wiki::DuplicatePageError, e.message
@@ -153,18 +146,17 @@ module Gitlab
end
end
- def gollum_update_page(page_path, title, format, ref, content, commit_details)
+ def gollum_update_page(page_path, title, format, content, commit_details)
assert_type!(format, Symbol)
assert_type!(commit_details, CommitDetails)
- gw = gollum_wiki(ref)
with_committer_with_hooks(commit_details) do |committer|
page = gollum_page_by_path(page_path)
# Instead of performing two renames if the title has changed,
# the update_page will only update the format and content and
# the rename_page will do anything related to moving/renaming
- gw.update_page(page, page.name, format, content, committer: committer)
- gw.rename_page(page, title, committer: committer)
+ gollum_wiki.update_page(page, page.name, format, content, committer: committer)
+ gollum_wiki.rename_page(page, title, committer: committer)
end
end