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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /lib/gitlab/changelog
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'lib/gitlab/changelog')
-rw-r--r--lib/gitlab/changelog/config.rb22
-rw-r--r--lib/gitlab/changelog/release.rb1
-rw-r--r--lib/gitlab/changelog/template.tpl2
3 files changed, 19 insertions, 6 deletions
diff --git a/lib/gitlab/changelog/config.rb b/lib/gitlab/changelog/config.rb
index 0538fe68474..fd5d701b858 100644
--- a/lib/gitlab/changelog/config.rb
+++ b/lib/gitlab/changelog/config.rb
@@ -34,17 +34,17 @@ module Gitlab
'(?:-(?P<pre>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))' \
'?(?:\+(?P<meta>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
- attr_accessor :date_format, :categories, :template, :tag_regex
+ attr_accessor :date_format, :categories, :template, :tag_regex, :always_credit_user_ids
- def self.from_git(project)
+ def self.from_git(project, user = nil)
if (yaml = project.repository.changelog_config)
- from_hash(project, YAML.safe_load(yaml))
+ from_hash(project, YAML.safe_load(yaml), user)
else
new(project)
end
end
- def self.from_hash(project, hash)
+ def self.from_hash(project, hash, user = nil)
config = new(project)
if (date = hash['date_format'])
@@ -72,6 +72,14 @@ module Gitlab
config.tag_regex = regex
end
+ config.always_credit_user_ids = Set.new
+ if (group_paths = Array(hash['include_groups']))
+ group_paths.each do |group_path|
+ group = Group.find_by_full_path(group_path)
+ config.always_credit_user_ids.merge(group&.users_ids_of_direct_members&.compact) if user&.can?(:read_group, group)
+ end
+ end
+
config
end
@@ -89,7 +97,11 @@ module Gitlab
end
def contributor?(user)
- @project.team.contributor?(user)
+ @project.team.contributor?(user&.id)
+ end
+
+ def always_credit_author?(user)
+ always_credit_user_ids&.include?(user&.id) || false
end
def category(name)
diff --git a/lib/gitlab/changelog/release.rb b/lib/gitlab/changelog/release.rb
index c0b6a5c5679..a0d598c7464 100644
--- a/lib/gitlab/changelog/release.rb
+++ b/lib/gitlab/changelog/release.rb
@@ -42,6 +42,7 @@ module Gitlab
'reference' => author.to_reference(full: true),
'contributor' => @config.contributor?(author)
}
+ entry['author']['credit'] = entry['author']['contributor'] || @config.always_credit_author?(author)
end
if merge_request
diff --git a/lib/gitlab/changelog/template.tpl b/lib/gitlab/changelog/template.tpl
index 584939dff51..68c1c624394 100644
--- a/lib/gitlab/changelog/template.tpl
+++ b/lib/gitlab/changelog/template.tpl
@@ -4,7 +4,7 @@
{% each entries %}
- [{{ title }}]({{ commit.reference }})\
-{% if author.contributor %} by {{ author.reference }}{% end %}\
+{% if author.credit %} by {{ author.reference }}{% end %}\
{% if merge_request %} ([merge request]({{ merge_request.reference }})){% end %}
{% end %}