2015-08-25 21:42:46 -04:00
|
|
|
module Ci
|
|
|
|
class CreateCommitService
|
2015-10-05 04:14:33 -04:00
|
|
|
def execute(project, params, user)
|
2015-08-25 21:42:46 -04:00
|
|
|
before_sha = params[:before]
|
|
|
|
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-02 07:46:38 -04:00
|
|
|
tag = origin_ref.start_with?('refs/tags/')
|
|
|
|
commit = project.gl_project.ensure_ci_commit(sha)
|
2015-08-25 21:42:46 -04:00
|
|
|
commit.update_committed!
|
2015-10-05 04:14:33 -04:00
|
|
|
commit.create_builds(ref, tag, user)
|
2015-08-25 21:42:46 -04:00
|
|
|
|
|
|
|
commit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|