Class: RJGit::RJGitUploadPack

Inherits:
RJGitPack show all
Defined in:
lib/transport.rb

Instance Attribute Summary

Attributes inherited from RJGitPack

#bidirectional, #jpack, #jrepo

Instance Method Summary collapse

Methods inherited from RJGitPack

#advertise_refs, #init_buffers

Constructor Details

#initialize(repository, bidirectional = false) ⇒ RJGitUploadPack

Returns a new instance of RJGitUploadPack.



57
58
59
60
# File 'lib/transport.rb', line 57

def initialize(repository, bidirectional = false)
  super
  @jpack = UploadPack.new(@jrepo)
end

Instance Method Details

#process(client_msg) ⇒ Object



62
63
64
# File 'lib/transport.rb', line 62

def process(client_msg)
  self.upload(client_msg)
end

#upload(client_msg) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/transport.rb', line 66

def upload(client_msg)
  in_stream, out_stream = init_buffers(client_msg)
  @jpack.set_bi_directional_pipe(@bidirectional)
  begin
    @jpack.upload(in_stream, out_stream, nil)
  rescue Java::OrgEclipseJgitErrors::InvalidObjectIdException, Java::OrgEclipseJgitTransport::UploadPackInternalServerErrorException, Java::JavaIo::IOException => e
    return nil, e
  end
  return ByteArrayInputStream.new(out_stream.to_byte_array).to_io, nil
end