require 'evrone/ci/common' module Evrone module CI module Worker LocalFetchRepo = Struct.new(:app) do include Common::Helper::Shell def call(env) scm = create_scm(env) if env.repo_dir if scm.fetch == 0 && export(scm, env) == 0 app.call env else -1 end else app.call env end end private def export(scm, env) cmd = scm.class.make_export_command env.repo_dir, env.work_dir env.job.add_command_to_output cmd bash cmd, &env.job.method(:add_to_output) end def create_scm(env) SCM::Git.new( env.job.message.src, env.job.message.sha, env.repo_dir, deploy_key: env.job.message.deploy_key, &env.job.method(:add_to_output) ) end end end end end