2015-09-25 12:07:36 +05:30
|
|
|
module Ci
|
|
|
|
class CreateCommitService
|
2015-10-24 18:46:33 +05:30
|
|
|
def execute(project, user, params)
|
2015-09-25 12:07:36 +05:30
|
|
|
sha = params[:checkout_sha] || params[:after]
|
|
|
|
origin_ref = params[:ref]
|
|
|
|
|
|
|
|
unless origin_ref && sha.present?
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
ref = origin_ref.gsub(/\Arefs\/(tags|heads)\//, '')
|
|
|
|
|
|
|
|
# Skip branch removal
|
|
|
|
if sha == Ci::Git::BLANK_SHA
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
tag = origin_ref.start_with?('refs/tags/')
|
|
|
|
commit = project.gl_project.ensure_ci_commit(sha)
|
|
|
|
unless commit.skip_ci?
|
|
|
|
commit.update_committed!
|
|
|
|
commit.create_builds(ref, tag, user)
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
commit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|