2015-08-25 21:42:46 -04:00
|
|
|
module Ci
|
|
|
|
class CreateCommitService
|
2015-10-05 07:12:00 -04:00
|
|
|
def execute(project, user, params)
|
2015-08-25 21:42:46 -04:00
|
|
|
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-10-12 10:35:58 -04:00
|
|
|
unless commit.skip_ci?
|
|
|
|
commit.update_committed!
|
|
|
|
commit.create_builds(ref, tag, user)
|
|
|
|
end
|
2015-10-12 10:39:08 -04:00
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
commit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|