Module: Dockly::Util::Git

Defined in:
lib/dockly/util/git.rb

Class Method Summary collapse

Class Method Details

.archive(oid, prefix, output) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dockly/util/git.rb', line 15

def archive(oid, prefix, output)
  prefix = prefix.dup
  unless prefix[-1] == '/'; prefix << '/'; end

  cmd = ['git','archive',"--prefix=#{prefix}",'--output=/dev/stdout',oid]
  Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
    stdin.close

    output.write(stdout.read)
    process_status = wait_thr.value
    exit_status = process_status.exitstatus

    raise "#{cmd.join(' ')} exitted non-zero: #{exit_status}" unless exit_status.zero?
  end
end

.repoObject



4
5
6
# File 'lib/dockly/util/git.rb', line 4

def repo
  @repo ||= MiniGit.new('.')
end

.shaObject



8
9
10
11
12
13
# File 'lib/dockly/util/git.rb', line 8

def sha
  return @sha if @sha
  @sha = repo.capturing.rev_parse('HEAD').chomp
rescue
  @sha = 'unknown'
end