Sha256: 02841e07589dbcfe70ecd5283506873f7274b5eb7f0f556447f156bd22e9ad19
Contents?: true
Size: 894 Bytes
Versions: 4
Compression:
Stored size: 894 Bytes
Contents
module Dockly::Util::Git module_function def repo @repo ||= Rugged::Repository.discover('.') end def sha return @sha if @sha @sha = repo.head.target.oid[0..6] rescue @sha = 'unknown' end def ls_files(oid) target = repo.lookup(oid) target = target.target until target.type == :commit ary = [] target.tree.walk(:postorder) do |root, entry| next unless entry[:type] == :blob name = File.join(root, entry[:name]).gsub(/\A\//, '') ary << entry.merge(name: name) end ary end def archive(oid, prefix, output) Gem::Package::TarWriter.new(output) do |tar| ls_files(oid).each do |blob| name, mode = blob.values_at(:name, :filemode) prefixed = File.join(prefix, name) tar.add_file(prefixed, mode) do |tar_out| tar_out.write(File.read(name)) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dockly-3.0.3 | lib/dockly/util/git.rb |
dockly-3.0.2 | lib/dockly/util/git.rb |
dockly-3.0.1 | lib/dockly/util/git.rb |
dockly-3.0.0 | lib/dockly/util/git.rb |