diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-08-30 13:00:18 +0300 |
---|---|---|
committer | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-08-31 04:27:41 +0300 |
commit | 7a57e59e1af9c2e3439c3d079515ea9164d16451 (patch) | |
tree | 7b382d5412eb98080f81660c1ca834884b969cdc /lib/gitlab/data_builder | |
parent | 3a0f3082af181c027df53cc367fc345f7fa52340 (diff) |
Use sample data for push event when no commits created
Diffstat (limited to 'lib/gitlab/data_builder')
-rw-r--r-- | lib/gitlab/data_builder/push.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb index c169c8fe135..b498f113859 100644 --- a/lib/gitlab/data_builder/push.rb +++ b/lib/gitlab/data_builder/push.rb @@ -97,11 +97,15 @@ module Gitlab } end - # This method provide a sample data generated with + # This method provides a sample data generated with # existing project and commits to test webhooks def build_sample(project, user) + # Use sample data if repo has no commit + # (expect the case of test service configuration settings) + return sample_data if project.empty_repo? + ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}#{project.default_branch}" - commits = project.repository.commits(project.default_branch.to_s, limit: 3) rescue [] + commits = project.repository.commits(project.default_branch.to_s, limit: 3) build(project, user, commits.last&.id, commits.first&.id, ref, commits) end |