diff options
Diffstat (limited to 'ruby/lib/gitlab')
-rw-r--r-- | ruby/lib/gitlab/git/repository.rb | 8 | ||||
-rw-r--r-- | ruby/lib/gitlab/git/wiki.rb | 9 |
2 files changed, 16 insertions, 1 deletions
diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb index a4d21f5e2..fad18e5b2 100644 --- a/ruby/lib/gitlab/git/repository.rb +++ b/ruby/lib/gitlab/git/repository.rb @@ -436,6 +436,14 @@ module Gitlab rugged&.close if defined?(@rugged) end + def head_symbolic_ref + message, status = run_git(%w[symbolic-ref HEAD]) + + return 'main' if status.nonzero? + + Ref.extract_branch_name(message.squish) + end + private def sparse_checkout_empty?(output) diff --git a/ruby/lib/gitlab/git/wiki.rb b/ruby/lib/gitlab/git/wiki.rb index 452351afd..506b4489f 100644 --- a/ruby/lib/gitlab/git/wiki.rb +++ b/ruby/lib/gitlab/git/wiki.rb @@ -60,11 +60,18 @@ module Gitlab end def gollum_wiki - @gollum_wiki ||= Gollum::Wiki.new(@repository.path) + options = {} + options[:ref] = gollum_default_ref if gollum_default_ref + + @gollum_wiki ||= Gollum::Wiki.new(@repository.path, options) end private + def gollum_default_ref + @gollum_default_ref ||= @repository.root_ref || @repository.head_symbolic_ref + end + def new_page(gollum_page) Gitlab::Git::WikiPage.new(gollum_page, new_version(gollum_page, gollum_page.version.id)) end |