Sha256: c7b64a88557ba473647e654e8bb0bc427a0008118df8c1c79aa320c9dc891d9e

Contents?: true

Size: 993 Bytes

Versions: 6

Compression:

Stored size: 993 Bytes

Contents

#!/usr/bin/env ruby

require "bundler/inline"
gemfile do
  source "https://rubygems.org"
  gem "multi_repo", require: "multi_repo/cli", path: File.expand_path("..", __dir__)
end
require 'more_core_extensions/core_ext/array/tableize'

opts = Optimist.options do
  synopsis "Show the commit for a tag in all git repos."

  opt :tag, "The tag name.", :type => :string, :required => true

  MultiRepo::CLI.common_options(self, :except => :dry_run, :repo_set_default => nil)
end
opts[:repo_set] = opts[:tag].split("-").first unless opts[:repo] || opts[:repo_set]

HEADER = %w(Repo SHA Message).freeze

def show_tag(repo, tag)
  line =
    begin
      repo.git.client.capturing.show({:summary => true, :oneline => true}, tag)
    rescue MiniGit::GitError => err
      ""
    end

  sha, message = line.split(" ", 2)
  [repo.name, sha, message]
end

repos = MultiRepo::CLI.repos_for(**opts)
table = [HEADER] + repos.collect { |repo| show_tag(repo, opts[:tag]) }
puts table.tableize(:max_width => 75)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
multi_repo-0.5.0 scripts/show_tag
multi_repo-0.4.0 scripts/show_tag
multi_repo-0.3.1 scripts/show_tag
multi_repo-0.3.0 scripts/show_tag
multi_repo-0.2.3 scripts/show_tag
multi_repo-0.2.2 scripts/show_tag