summaryrefslogtreecommitdiff
path: root/app/models/snippet.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-13 12:10:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-13 12:10:02 +0000
commit3748ae5cbbefd3de0111951e71e74b676c276d61 (patch)
treeec12be349757c64eafaafdacd0eb7699adff113b /app/models/snippet.rb
parent19325d74c2a5e7f367c6d1d6a064650f90a5b3e7 (diff)
downloadgitlab-ce-3748ae5cbbefd3de0111951e71e74b676c276d61.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/snippet.rb')
-rw-r--r--app/models/snippet.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 4f64c074856..7beeb106735 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -20,7 +20,6 @@ class Snippet < ApplicationRecord
extend ::Gitlab::Utils::Override
MAX_FILE_COUNT = 10
- MASTER_BRANCH = 'master'
cache_markdown_field :title, pipeline: :single_line
cache_markdown_field :description
@@ -316,19 +315,19 @@ class Snippet < ApplicationRecord
override :default_branch
def default_branch
- super || MASTER_BRANCH
+ super || Gitlab::DefaultBranch.value(project: project)
end
def repository_storage
snippet_repository&.shard_name || Repository.pick_storage_shard
end
- # Repositories are created by default with the `master` branch.
+ # Repositories are created with a default branch. This branch
+ # can be different from the default branch set in the platform.
# This method changes the `HEAD` file to point to the existing
- # default branch in case it's not master.
+ # default branch in case it's different.
def change_head_to_default_branch
return unless repository.exists?
- return if default_branch == MASTER_BRANCH
# All snippets must have at least 1 file. Therefore, if
# `HEAD` is empty is because it's pointing to the wrong
# default branch