Sha256: ec08686c7b67fba99a06545e7af7a46c8d8f228309d8d489105bb097c5ba7a2c
Contents?: true
Size: 980 Bytes
Versions: 2
Compression:
Stored size: 980 Bytes
Contents
# frozen_string_literal: true require 'fileutils' require 'rugged' module GitMQueue class Storage attr_reader :repo, :path def initialize(path) @path = path @repo = read_or_create_repo end def branches repo.branches end def branch(name) branches[name] end def tree Rugged::Tree::Builder.new(repo).write end 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 def tag(label, commit) repo.tags.create(label, commit, true) end private 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gitmqueue-0.1.2 | lib/storage.rb |
gitmqueue-0.1.1 | lib/storage.rb |