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>2023-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /lib/gitlab/data_builder
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'lib/gitlab/data_builder')
-rw-r--r--lib/gitlab/data_builder/build.rb7
-rw-r--r--lib/gitlab/data_builder/emoji.rb45
-rw-r--r--lib/gitlab/data_builder/push.rb3
3 files changed, 50 insertions, 5 deletions
diff --git a/lib/gitlab/data_builder/build.rb b/lib/gitlab/data_builder/build.rb
index 8fec5cf3303..e1e9e4720bb 100644
--- a/lib/gitlab/data_builder/build.rb
+++ b/lib/gitlab/data_builder/build.rb
@@ -12,13 +12,14 @@ module Gitlab
author_url = build_author_url(build.commit, commit)
- data = {
+ {
object_kind: 'build',
ref: build.ref,
tag: build.tag,
before_sha: build.before_sha,
sha: build.sha,
+ retries_count: build.retries_count,
# TODO: should this be not prefixed with build_?
# Leaving this way to have backward compatibility
@@ -69,10 +70,6 @@ module Gitlab
environment: build_environment(build)
}
-
- data[:retries_count] = build.retries_count if Feature.enabled?(:job_webhook_retries_count, project)
-
- data
end
private
diff --git a/lib/gitlab/data_builder/emoji.rb b/lib/gitlab/data_builder/emoji.rb
new file mode 100644
index 00000000000..63562eca155
--- /dev/null
+++ b/lib/gitlab/data_builder/emoji.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module DataBuilder
+ module Emoji
+ extend self
+
+ def build(award_emoji, user, action)
+ project = award_emoji.awardable.project
+ data = build_base_data(project, user, award_emoji, action)
+
+ if award_emoji.awardable.is_a?(::Note)
+ note = award_emoji.awardable
+ data[:note] = note.hook_attrs
+ noteable = note.noteable
+ else
+ noteable = award_emoji.awardable
+ end
+
+ if noteable.respond_to?(:hook_attrs)
+ data[noteable.class.underscore.to_sym] = noteable.hook_attrs
+ else
+ Gitlab::AppLogger.error(
+ "Error building payload data for emoji webhook. #{noteable.class} does not respond to hook_attrs.")
+ end
+
+ data
+ end
+
+ def build_base_data(project, user, award_emoji, action)
+ base_data = {
+ object_kind: 'emoji',
+ event_type: action,
+ user: user.hook_attrs,
+ project_id: project.id,
+ project: project.hook_attrs,
+ object_attributes: award_emoji.hook_attrs
+ }
+
+ base_data[:object_attributes][:awarded_on_url] = Gitlab::UrlBuilder.build(award_emoji.awardable)
+ base_data
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb
index f941c57a6dd..46110937132 100644
--- a/lib/gitlab/data_builder/push.rb
+++ b/lib/gitlab/data_builder/push.rb
@@ -12,6 +12,7 @@ module Gitlab
before: "95790bf891e76fee5e1747ab589903a6a1f80f22",
after: "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
ref: "refs/heads/master",
+ ref_protected: true,
checkout_sha: "da1560886d4f094c3e6c9ef40349f7d38b5d27d7",
message: "Hello World",
user_id: 4,
@@ -55,6 +56,7 @@ module Gitlab
# before: String,
# after: String,
# ref: String,
+ # ref_protected: Boolean,
# user_id: String,
# user_name: String,
# user_username: String,
@@ -116,6 +118,7 @@ module Gitlab
before: oldrev,
after: newrev,
ref: ref,
+ ref_protected: project.protected_for?(ref),
checkout_sha: checkout_sha(project.repository, newrev, ref),
message: message,
user_id: user.id,