Skip to content
Snippets Groups Projects
Commit 7a57e59e authored by Takuya Noguchi's avatar Takuya Noguchi
Browse files

Use sample data for push event when no commits created

parent 3a0f3082
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
---
title: Use sample data for push event when no commits created
merge_request: 21440
author: Takuya Noguchi
type: fixed
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment