Sha256: 2c9aaa8acfb50f6c740a36e6b835ee9295888791aea87e80dc9f5b14432e130e

Contents?: true

Size: 786 Bytes

Versions: 11

Compression:

Stored size: 786 Bytes

Contents

module Shipit
  class Commands
    class << self
      def for(model)
        "#{model.class.name}Commands".constantize.new(model)
      end

      def git_version
        @git_version ||= parse_git_version(`git --version`)
      end

      def parse_git_version(raw_git_version)
        raw_git_version =~ /(\d+\.\d+\.\d+)/
        raise 'git command not found' unless $1
        Gem::Version.new($1)
      end
    end

    delegate :git_version, to: :class

    def env
      @env ||= Shipit.env.merge(
        'GITHUB_DOMAIN' => Shipit.github.domain,
        'GITHUB_TOKEN' => Shipit.github.token,
        'GIT_ASKPASS' => Shipit::Engine.root.join('lib', 'snippets', 'git-askpass').realpath.to_s,
      )
    end

    def git(*args)
      Command.new("git", *args)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 lib/shipit/commands.rb
shipit-engine-0.30.0 lib/shipit/commands.rb
shipit-engine-0.29.0 lib/shipit/commands.rb
shipit-engine-0.28.1 lib/shipit/commands.rb
shipit-engine-0.28.0 lib/shipit/commands.rb
shipit-engine-0.27.1 lib/shipit/commands.rb
shipit-engine-0.27.0 lib/shipit/commands.rb
shipit-engine-0.26.0 lib/shipit/commands.rb
shipit-engine-0.25.1 lib/shipit/commands.rb
shipit-engine-0.25.0 lib/shipit/commands.rb
shipit-engine-0.24.0 lib/shipit/commands.rb