Sha256: 77ebea121867a954370bdab0a0d7d87a1492c4e0f510a8bcdfc635a4fc314875

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

module Releasecop
  class Checker
    attr_accessor :name, :envs

    def initialize(name, envs)
      self.name = name
      self.envs = envs
    end

    # Reports status of individual project. Returns count of out-of-date environments.
    def check
      puts "#{name}..."
      unreleased = 0
      Dir.chdir(CONFIG_DIR) do
        `git clone #{envs.first['git']} --bare #{name} > /dev/null 2>&1`
        Dir.chdir(name) do
          envs.each do |env|
            `git remote add #{env['name']} #{env['git']} > /dev/null 2>&1`
            `git fetch #{env['name']} > /dev/null 2>&1`
          end
          envs.each_cons(2) do |ahead, behind|
            log = `git log #{behind['name']}/#{behind['branch'] || 'master'}..#{ahead['name']}/#{ahead['branch'] || 'master'} --pretty=format:"%h %ad %s (%an)" --date=short --no-merges`
            if log == ''
              puts "  #{behind['name']} is up-to-date with #{ahead['name']}\n"
            else
              puts "  #{behind['name']} is behind #{ahead['name']} by:"
              log.lines.each { |l| puts "    #{l}" }
              unreleased += 1
            end
          end
        end
      end
      unreleased
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
releasecop-0.0.3 lib/releasecop/checker.rb
releasecop-0.0.2 lib/releasecop/checker.rb
releasecop-0.0.1 lib/releasecop/checker.rb