Sha256: e7d72282233a83fd00d05cf985873c5f455defaf5af249ab9e67a0ba9e895a62

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 Bytes

Contents

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre4 lib/evrone/ci/worker/middlewares/local_fetch_repo.rb
evrone-ci-worker-0.2.0.pre3 lib/evrone/ci/worker/middlewares/local_fetch_repo.rb
evrone-ci-worker-0.2.0.pre1 lib/evrone/ci/worker/middlewares/local_fetch_repo.rb
evrone-ci-worker-0.2.0.pre0 lib/evrone/ci/worker/middlewares/local_fetch_repo.rb