Sha256: 4068b224ec69152e056aa1c01bc49d751d1cc725d5ac13aceee935b814ced7da

Contents?: true

Size: 841 Bytes

Versions: 6

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true

require_relative './base'

module Treeish
  class Tag < Base
    private

    def recents_command
      'git tag --sort=-committerdate'
    end

    def reject_strategy(line, _)
      false
    end

    def value_strategy(line, _)
      line.strip
    end

    def name_strategy(line, _)
      if line.match(/^#{current}$/)
        "* #{line.strip}"
      else
        "  #{line.strip}"
      end
    end

    def current
      # git describe --exact-match --tags $(git log -n1 --pretty='%h')
      cmd = "git log -n1 --pretty='%h'"
      _stdin, stdout, _stderr, _wait_thr = Open3.popen3(cmd)
      last_commit = stdout.read.strip

      cmd = "git describe --exact-match --tags #{last_commit}"
      _stdin, stdout, _stderr, _wait_thr = Open3.popen3(cmd)
      stdout.read.strip || '[\s]+'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gnav-0.6.4 lib/treeish/tag.rb
gnav-0.6.3 lib/treeish/tag.rb
gnav-0.6.2 lib/treeish/tag.rb
gnav-0.6.1 lib/treeish/tag.rb
gnav-0.6.0 lib/treeish/tag.rb
gnav-0.5.2 lib/treeish/tag.rb