Sha256: f9c5e1fe0f84421ddf7b5b41a6b6bf85d615a7c147a8a6e1679515a1e6b52b98
Contents?: true
Size: 866 Bytes
Versions: 1
Compression:
Stored size: 866 Bytes
Contents
# frozen_string_literal: true require 'git' require 'open3' class TreeishExtractor attr_reader :git def initialize(git: nil) @git = git || Git.open(Dir.pwd) end def recent_tag_names # TODO unlimit number of tags when arg is given cmd = "git describe --tags $(git rev-list --tags --max-count=1000)" get_treeish_names(cmd) end def recent_branch_names # TODO limit number of branches when arg is not given cmd = 'git branch --sort=-committerdate' get_treeish_names(cmd) end private def get_treeish_names(cmd) names = [] _stdin, stdout, _stderr, _wait_thr = Open3.popen3(cmd) stdout.each(sep="\n") do |line| # reject rev without a tag # current branch has '* ' to indicate it's selected names << line.strip.sub('* ', '') unless line =~ /-[\d]+-[a-z0-9]{8,}$/ end names end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_selector-0.2.0 | lib/treeish_extractor.rb |