Sha256: 4d44185372471fb5ca6f4af417dee363e027d15330a3cc0f4ac83da06c61a22c

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

module GitBumper
  # This module has some functions to deal with a git repository.
  module Git
    module_function

    # Returns true if the current working directory has a git repository.
    #
    # @return [Boolean]
    def repo?
      system('git rev-parse --is-inside-work-tree >/dev/null 2>&1')
    end

    # Fetches all git tags.
    def fetch_tags
      system('git fetch --tags >/dev/null 2>&1')
    end

    # Returns the greatest tag.
    def greatest_tag(prefix: 'v', tag_class: Tag)
      output = `git tag --list --sort=-v:refname "#{prefix}[0-9]*" 2> /dev/null`

      tags = output.split.collect do |tag|
        tag_class.parse(tag)
      end

      tags.find do |tag|
        tag
      end || false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_bumper-0.1.0 lib/git_bumper/git.rb