summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-15 17:54:42 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-15 17:54:42 +0200
commit0674bf2339131c104b233cb9c7ffeeb025f2b461 (patch)
treebbe89762e5a9c8e1785997a1d92431eb0b3fa0f4 /app/models
parentfe51fa26a777f239dc4a09f531b54162f9f949fc (diff)
downloadgitlab-ce-0674bf2339131c104b233cb9c7ffeeb025f2b461.tar.gz
Look for .gitlab-ci.yml only if checkout_sha is presentfix-gitlab-ci-yml
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project_services/gitlab_ci_service.rb22
1 files changed, 13 insertions, 9 deletions
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index a9354754686..19b5859d5c9 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -40,10 +40,14 @@ class GitlabCiService < CiService
def execute(data)
return unless supported_events.include?(data[:object_kind])
- ci_yaml_file = ci_yaml_file(data)
+ sha = data[:checkout_sha]
- if ci_yaml_file
- data.merge!(ci_yaml_file: ci_yaml_file)
+ if sha.present?
+ file = ci_yaml_file(sha)
+
+ if file && file.data
+ data.merge!(ci_yaml_file: file.data)
+ end
end
service_hook.execute(data)
@@ -129,15 +133,15 @@ class GitlabCiService < CiService
private
- def ci_yaml_file(data)
- ref = data[:checkout_sha]
- repo = project.repository
- commit = repo.commit(ref)
- blob = Gitlab::Git::Blob.find(repo, commit.id, ".gitlab-ci.yml")
- blob && blob.data
+ def ci_yaml_file(sha)
+ repository.blob_at(sha, '.gitlab-ci.yml')
end
def fork_registration_path
project_url.sub(/projects\/\d*/, "#{API_PREFIX}/forks")
end
+
+ def repository
+ project.repository
+ end
end