summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-15 16:29:19 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-15 16:29:19 +0000
commit5fa0248966316d672429eabc46407e1429ef2283 (patch)
treebbe89762e5a9c8e1785997a1d92431eb0b3fa0f4 /app
parentcbba28bdb6dbb6eae297e7040938de06e70bc6d8 (diff)
parent0674bf2339131c104b233cb9c7ffeeb025f2b461 (diff)
downloadgitlab-ce-5fa0248966316d672429eabc46407e1429ef2283.tar.gz
Merge branch 'fix-gitlab-ci-yml' into 'master'
Look for .gitlab-ci.yml only if checkout_sha is present Fixes https://dev.gitlab.org/gitlab/gitlabhq/issues/2396 cc @vsizov See merge request !818
Diffstat (limited to 'app')
-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