Class: RJGit::RJGitPack

Inherits:
Object
  • Object
show all
Defined in:
lib/transport.rb

Direct Known Subclasses

RJGitReceivePack, RJGitUploadPack

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, bidirectional = false) ⇒ RJGitPack

Returns a new instance of RJGitPack.



13
14
15
16
# File 'lib/transport.rb', line 13

def initialize(repository, bidirectional = false)
  @jrepo = RJGit.repository_type(repository)
  @bidirectional = bidirectional
end

Instance Attribute Details

#bidirectionalObject

Returns the value of attribute bidirectional.



11
12
13
# File 'lib/transport.rb', line 11

def bidirectional
  @bidirectional
end

#jpackObject

Returns the value of attribute jpack.



11
12
13
# File 'lib/transport.rb', line 11

def jpack
  @jpack
end

#jrepoObject

Returns the value of attribute jrepo.



11
12
13
# File 'lib/transport.rb', line 11

def jrepo
  @jrepo
end

Instance Method Details



18
19
20
21
22
23
24
# File 'lib/transport.rb', line 18

def advertise_refs
  out_stream = ByteArrayOutputStream.new
  pck_out = PacketLineOut.new(out_stream)
  advertiser = PacketLineOutRefAdvertiser.new(pck_out)
  @jpack.sendAdvertisedRefs(advertiser)
  return out_stream.to_string
end

#process(client_msg) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/transport.rb', line 26

def process(client_msg)
  input, output = init_buffers(client_msg)
  @jpack.set_bi_directional_pipe(@bidirectional)
  begin
    @jpack.send(@action, input, output, nil)
  rescue Java::OrgEclipseJgitErrors::InvalidObjectIdException, Java::OrgEclipseJgitTransport::UploadPackInternalServerErrorException, Java::JavaIo::IOException => e
    return nil, e
  end
  return ByteArrayInputStream.new(output.to_byte_array).to_io, nil
end