Method: Git::Lib#archive

Defined in:
lib/git/lib.rb

#archive(sha, file = nil, opts = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
# File 'lib/git/lib.rb', line 1623

def archive(sha, file = nil, opts = {})
  ArgsBuilder.validate!(opts, ARCHIVE_OPTION_MAP)
  file ||= temp_file_name
  format, gzip = parse_archive_format_options(opts)

  args = build_args(opts, ARCHIVE_OPTION_MAP)
  args.unshift("--format=#{format}")
  args << sha
  args.push('--', opts[:path]) if opts[:path]

  File.open(file, 'wb') { |f| command('archive', *args, out: f) }
  apply_gzip(file) if gzip

  file
end