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-10.1.0 lib/milestoner/git/kit.rb
milestoner-10.0.2 lib/milestoner/git/kit.rb
milestoner-10.0.1 lib/milestoner/git/kit.rb
milestoner-10.0.0 lib/milestoner/git/kit.rb
milestoner-9.3.3 lib/milestoner/git/kit.rb
milestoner-9.3.2 lib/milestoner/git/kit.rb
milestoner-9.3.1 lib/milestoner/git/kit.rb
milestoner-9.3.0 lib/milestoner/git/kit.rb
milestoner-9.2.1 lib/milestoner/git/kit.rb
milestoner-9.2.0 lib/milestoner/git/kit.rb
milestoner-9.1.0 lib/milestoner/git/kit.rb
milestoner-9.0.0 lib/milestoner/git/kit.rb
milestoner-8.3.0 lib/milestoner/git/kit.rb
milestoner-8.2.0 lib/milestoner/git/kit.rb
milestoner-8.1.0 lib/milestoner/git/kit.rb
milestoner-8.0.0 lib/milestoner/git/kit.rb
milestoner-7.0.1 lib/milestoner/git/kit.rb
milestoner-7.0.0 lib/milestoner/git/kit.rb
milestoner-6.3.1 lib/milestoner/git/kit.rb
milestoner-6.3.0 lib/milestoner/git/kit.rb