Module: Command::RemoteAgent
- Included in:
- ReceivePack, UploadPack
- Defined in:
- lib/command/shared/remote_agent.rb
Constant Summary collapse
- ZERO_OID =
"0" * 40
Instance Method Summary collapse
- #accept_client(name, capabilities = []) ⇒ Object
- #detect_git_dir ⇒ Object
- #git_repository?(dirname) ⇒ Boolean
- #repo ⇒ Object
- #send_references ⇒ Object
Instance Method Details
#accept_client(name, capabilities = []) ⇒ Object
9 10 11 |
# File 'lib/command/shared/remote_agent.rb', line 9 def accept_client(name, capabilities = []) @conn = Remotes::Protocol.new(name, @stdin, @stdout, capabilities) end |
#detect_git_dir ⇒ Object
17 18 19 20 21 |
# File 'lib/command/shared/remote_agent.rb', line 17 def detect_git_dir pathname = (@args[0]) dirs = pathname.ascend.flat_map { |dir| [dir, dir.join(".git")] } dirs.find { |dir| git_repository?(dir) } end |
#git_repository?(dirname) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/command/shared/remote_agent.rb', line 23 def git_repository?(dirname) File.file?(dirname.join("HEAD")) and File.directory?(dirname.join("objects")) and File.directory?(dirname.join("refs")) end |
#repo ⇒ Object
13 14 15 |
# File 'lib/command/shared/remote_agent.rb', line 13 def repo @repo ||= Repository.new(detect_git_dir) end |
#send_references ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/command/shared/remote_agent.rb', line 29 def send_references refs = repo.refs.list_all_refs sent = false refs.sort_by(&:path).each do |symref| next unless oid = symref.read_oid @conn.send_packet("#{ oid.downcase } #{ symref.path }") sent = true end @conn.send_packet("#{ ZERO_OID } capabilities^{}") unless sent @conn.send_packet(nil) end |