Sha256: b7498fc6b8a635ab11d1856ded009eeb0b5035f5c46469e066c4647ea21859fd

Contents?: true

Size: 854 Bytes

Versions: 24

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

module Milestoner
  module Git
    # A lightweight Git wrapper.
    class Kit
      def initialize
        @git_dir = File.join Dir.pwd, ".git"
      end

      def supported?
        File.exist? git_dir
      end

      def commits?
        !shell("git log").empty?
      end

      def push_tags
        shell "git push --tags"
      end

      def tagged?
        !shell("git tag").empty?
      end

      def tag_local? tag
        shell("git tag --list #{tag}").match?(/\A#{tag}\Z/)
      end

      def tag_remote? tag
        shell("git ls-remote --tags origin #{tag}").match?(%r(.+tags\/#{tag}\Z))
      end

      def remote?
        !shell("git config remote.origin.url").empty?
      end

      private

      attr_reader :git_dir

      def shell command
        String `#{command}`
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
milestoner-6.2.0 lib/milestoner/git/kit.rb
milestoner-6.1.0 lib/milestoner/git/kit.rb
milestoner-6.0.0 lib/milestoner/git/kit.rb
milestoner-5.1.0 lib/milestoner/git/kit.rb