Sha256: 25956465604af0c932e5bb3a586e81212f6f5605a661cc78917d765e48940621

Contents?: true

Size: 784 Bytes

Versions: 3

Compression:

Stored size: 784 Bytes

Contents

require 'fileutils'
require 'git'

module Vendorificator
  module TestSupport
    module Git
      def git(*args)
        @git ||= {}
        @git[args] ||= ::Git.init(*args)
      end

      def commit_file(path, contents, message=nil)
        message ||= "Added #{path}"
        FileUtils.mkdir_p(File.dirname(path))
        File.open(path, 'w') { |f| f.puts(contents) }
        git.add(path)
        git.commit(message)
      end

      def repo_clean?
        # FIXME: How to do that with ruby-git?
        `git status --porcelain` == ""
      end

      def branch
        git.current_branch
      end

      def branches
        git.branches.map(&:to_s)
      end

      def tags
        git.tags.map(&:name)
      end
    end
  end
end

World(Vendorificator::TestSupport::Git)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vendorificator-0.1.1 features/support/world_git.rb
vendorificator-0.1.0 features/support/world_git.rb
vendorificator-0.0.1 features/support/world_git.rb