gitlab-org--gitlab-foss/app/services/ci/create_commit_service.rb

28 lines
640 B
Ruby
Raw Normal View History

2015-08-25 21:42:46 -04:00
module Ci
class CreateCommitService
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!
commit.create_builds(ref, tag, user)
2015-08-25 21:42:46 -04:00
commit
end
end
end