Class: Git::StreamCommit

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

Overview

Stream Classes

These classes must support the following methods

to_s - write the command to the git protocol stream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStreamCommit

Returns a new instance of StreamCommit.



18
19
20
21
22
23
24
25
26
# File 'lib/git/stream.rb', line 18

def initialize()
  @branch = nil
  @mark = StreamMark.new
  @author = nil
  @committer = nil
  @message = nil
  @ancestor = nil
  @changes = []
end

Instance Attribute Details

#ancestorObject

Returns the value of attribute ancestor.



16
17
18
# File 'lib/git/stream.rb', line 16

def ancestor
  @ancestor
end

#authorObject

Returns the value of attribute author.



16
17
18
# File 'lib/git/stream.rb', line 16

def author
  @author
end

#branchObject

Returns the value of attribute branch.



16
17
18
# File 'lib/git/stream.rb', line 16

def branch
  @branch
end

#changesObject

Returns the value of attribute changes.



16
17
18
# File 'lib/git/stream.rb', line 16

def changes
  @changes
end

#committerObject

Returns the value of attribute committer.



16
17
18
# File 'lib/git/stream.rb', line 16

def committer
  @committer
end

#markObject

Returns the value of attribute mark.



16
17
18
# File 'lib/git/stream.rb', line 16

def mark
  @mark
end

#messageObject

Returns the value of attribute message.



16
17
18
# File 'lib/git/stream.rb', line 16

def message
  @message
end

Instance Method Details

#copy_file(repos_path_from, repos_path_to) ⇒ Object



42
43
44
# File 'lib/git/stream.rb', line 42

def copy_file(repos_path_from, repos_path_to)
  changes << StreamFileCopy.new(repos_path_form, repos_path_to)
end

#delete_all_filesObject



46
47
48
# File 'lib/git/stream.rb', line 46

def delete_all_files()
  changes << StreamFileDeleteAll.new
end

#delete_file(repos_path) ⇒ Object



34
35
36
# File 'lib/git/stream.rb', line 34

def delete_file(repos_path)
  changes << StreamFileDelete.new(repos_path)
end

#modify_file(repos_path, data, mode = nil) ⇒ Object



28
29
30
31
32
# File 'lib/git/stream.rb', line 28

def modify_file(repos_path, data, mode = nil)
  sfm = StreamFileModify.new(repos_path, data)
  sfm.mode = mode unless mode == nil
  changes << sfm
end

#rename_file(repos_path_from, repos_path_to) ⇒ Object



38
39
40
# File 'lib/git/stream.rb', line 38

def rename_file(repos_path_from, repos_path_to)
  changes << StreamFileRename.new(repos_path_form, repos_path_to)
end

#to_sObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/git/stream.rb', line 50

def to_s 
  out = "commit refs/heads/#{branch.to_s}\n"
  out << "mark #{mark}\n" 
  out << "author #{author.name} <#{author.email}> #{author.date.rfc2822}\n" unless author == nil
  out << "committer #{committer.name} <#{committer.email}> #{committer.date.rfc2822}\n" unless committer == nil
  if (message == nil)
    out << StreamData.emit_empty_data
  else
    out << StreamData.emit_inline_data(message)
  end
  out << "from #{ancestor}\n" unless ancestor == nil
  changes.each do |c|
    out << c.to_s
  end
  out << "\n"
end