class GitMQ::Storage

Attributes

path[R]
repo[R]

Public Class Methods

new(path) click to toggle source
# File lib/storage.rb, line 10
def initialize(path)
  @path = path
  @repo = read_or_create_repo
end

Public Instance Methods

branch(name) click to toggle source
# File lib/storage.rb, line 19
def branch(name)
  branches[name]
end
branches() click to toggle source
# File lib/storage.rb, line 15
def branches
  repo.branches
end
commits(branch, tag) click to toggle source
# File lib/storage.rb, line 27
def commits(branch, tag)
  walker = Rugged::Walker.new(repo)
  walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
  walker.push(branch(branch).target)

  tag = repo.tags[tag]
  walker.hide(tag.target) if tag
  walker
end
tag(label, commit) click to toggle source
# File lib/storage.rb, line 37
def tag(label, commit)
  repo.tags.create(label, commit, true)
end
tree() click to toggle source
# File lib/storage.rb, line 23
def tree
  Rugged::Tree::Builder.new(repo).write
end

Private Instance Methods

read_or_create_repo() click to toggle source
# File lib/storage.rb, line 43
def read_or_create_repo
  FileUtils.mkdir_p(path) unless File.exist?(path)
  begin
    Rugged::Repository.new(path)
  rescue Rugged::RepositoryError
    Rugged::Repository.init_at(path, :bare)
  end
end