class Releaser::Repo

Attributes

repo[RW]

Public Class Methods

new(path = '.') click to toggle source
# File lib/releaser.rb, line 51
def initialize(path = '.')
  @repo = Rugged::Repository.new(Rugged::Repository.discover(path))
end

Public Instance Methods

all_change_logs() click to toggle source
# File lib/releaser.rb, line 82
def all_change_logs
  start_tag = Tag.new("HEAD", repo.last_commit)
  start_on = start_tag.oid == tags.first.oid ? nil : start_tag

  change_logs = []
  tags.reduce(start_on) do |start_tag, end_tag|
    if start_tag
      commits = commits_between(start_tag.commit, end_tag.commit)
      change_logs << ChangeLog.new(self, start_tag, commits)
    end
    end_tag
  end

  change_logs
end
commits_between(start_ref, end_ref) click to toggle source
# File lib/releaser.rb, line 98
def commits_between(start_ref, end_ref)
  commits = []
  repo.walk(start_ref.oid) do |commit|
    break if commit.oid == end_ref.oid
    commits << commit
  end

  commits
end
create_release(tag_name) click to toggle source
# File lib/releaser.rb, line 63
def create_release(tag_name)
  Rugged::Reference.create(repo, "refs/tags/#{tag_name}", repo.last_commit.oid)
end
last_change_log() click to toggle source
# File lib/releaser.rb, line 67
def last_change_log
  raise "Not enough tags in repo" if tags.length < 1

  # Need at least one tag in the repo (two if it's the current commit)
  if tags.first.oid == repo.last_commit.oid
    start_tag = tags.first
    end_tag = tags[1]
  else
    start_tag = Tag.new("HEAD", repo.last_commit)
    end_tag = tags[0]
  end

  ChangeLog.new(self, start_tag, commits_between(repo.last_commit, end_tag.commit))
end
tags() click to toggle source
# File lib/releaser.rb, line 55
def tags
  @tags ||= repo.tags.map do |tagname|
    rev = repo.rev_parse(tagname)
    commit = rev.respond_to?(:target) ? rev.target : rev
    Tag.new(tagname, commit)
  end.sort_by(&:time).reverse
end