summaryrefslogtreecommitdiff
path: root/lib/gitlab/data_builder
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-04-24 16:23:51 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-04-27 18:36:10 +0100
commit6368072fd7bbee0f79de358aa8645f463d768bef (patch)
tree138a124acaf8be204a2529397b26917a9fe3ee8a /lib/gitlab/data_builder
parentc768026474b9dff9f6f988372e4eefb85b1d8be9 (diff)
downloadgitlab-ce-6368072fd7bbee0f79de358aa8645f463d768bef.tar.gz
improves test settings for chat notification services for empty projects31138-improve-test-settings-for-services-in-empty-projects
Diffstat (limited to 'lib/gitlab/data_builder')
-rw-r--r--lib/gitlab/data_builder/push.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb
index d76aa38f741..1ff34553f0a 100644
--- a/lib/gitlab/data_builder/push.rb
+++ b/lib/gitlab/data_builder/push.rb
@@ -41,7 +41,7 @@ module Gitlab
type = Gitlab::Git.tag_ref?(ref) ? 'tag_push' : 'push'
# Hash to be passed as post_receive_data
- data = {
+ {
object_kind: type,
event_name: type,
before: oldrev,
@@ -61,16 +61,15 @@ module Gitlab
repository: project.hook_attrs.slice(:name, :url, :description, :homepage,
:git_http_url, :git_ssh_url, :visibility_level)
}
-
- data
end
# This method provide a sample data generated with
# existing project and commits to test webhooks
def build_sample(project, user)
- commits = project.repository.commits(project.default_branch, limit: 3)
ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}#{project.default_branch}"
- build(project, user, commits.last.id, commits.first.id, ref, commits)
+ commits = project.repository.commits(project.default_branch.to_s, limit: 3) rescue []
+
+ build(project, user, commits.last&.id, commits.first&.id, ref, commits)
end
def checkout_sha(repository, newrev, ref)