Commit e6e39576 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Backups: extracted a Project.has_git_repo? method

This was suggested in comment and it really makes sense, now.
In the case of Wikis, care must be taken that this will be called
on the `ProjectWiki` instance.

branch : heptapod
parent 39e5006686df
......@@ -40,6 +40,7 @@ class Project < ApplicationRecord
BoardLimitExceeded =
MERCURIAL_VCS_TYPES = %w[hg hg_git].freeze
VCS_TYPES_WITH_GIT_REPO = %w[hg_git git].freeze
STATISTICS_ATTRIBUTE = 'repositories_count'
UNKNOWN_IMPORT_URL = 'http://unknown.git'
# Hashed Storage versions handle rolling out new storage to project and dependents models:
......@@ -891,6 +892,12 @@ def mercurial?
def has_git_repo?
# currently, even "Mercurial native" Projects actually use an
# auxiliary Git repo. This knowledge is essential for backups
def empty_repo?
......@@ -40,7 +40,9 @@ def initialize(container, user = nil)
raise ArgumentError, "user must be a User, got #{user.class}" if user && !user.is_a?(User)
delegate :vcs_type, :mercurial?, to: :project
# TODO GitLab 13.5 introduces Group Wikis IIRC. We may want to move
# this down to ProjectWiki subclass
delegate :vcs_type, :mercurial?, :has_git_repo?, to: :project
def path
container.path + '.wiki'
......@@ -56,8 +56,7 @@ def dump(max_concurrency:, max_storage_concurrency:)
def backup_project(project)
path_to_project_bundle = path_to_bundle(project)
# TODO make a project method out of this
has_git = ["git", "hg_git"].include?(project.vcs_type)
has_git = project.has_git_repo?
if has_git
......@@ -124,8 +123,7 @@ def restore_custom_hooks(project)
def restore
Project.find_each(batch_size: 1000) do |project|
progress.print " * #{display_repo_path(project)} ... "
# TODO make a project method out of this
has_git = ["git", "hg_git"].include?(project.vcs_type)
has_git = project.has_git_repo?
restore_repo_success =
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