Class: GitWrapper::Commands::Log
- Inherits:
-
Git
- Object
- Git
- GitWrapper::Commands::Log
show all
- Defined in:
- lib/git_wrapper/commands/log.rb
Constant Summary
collapse
- ATTRIBUTES =
{
:commit_hash => 'H',
:abbreviated_commit_hash => 'h',
:tree_hash => 'T',
:abbreviated_tree_hash => 't',
:parent_hashes => 'P',
:abbreviated_parent_hashes => 'p',
:author_name => 'an',
:author_name_mailmap => 'aN',
:author_email => 'ae',
:author_email_mailmap => 'aE',
:author_date => 'ad',
:author_date_rfc2822 => 'aD',
:author_date_relative => 'aR',
:author_date_unix => 'at',
:author_date_iso => 'ai',
:commiter_name => 'cn',
:commiter_name_mailmap => 'cN',
:commiter_email => 'ce',
:commiter_email_mailmap => 'cE',
:commiter_date => 'cd',
:commiter_date_rfc2822 => 'cD',
:commiter_date_relative => 'cR',
:commiter_date_unix => 'ct',
:commiter_date_iso => 'ci',
:ref_names => 'd',
:encoding => 'e',
:subject => 's',
:sanitized_subject_line => 'f',
:body => 'b',
:raw_body => 'B',
:commit_notes => 'N',
:reflog_selector => 'gD',
:shortened_reflog_selector => 'gd',
:reflog_subject => 'gs'
}
Instance Attribute Summary
Attributes inherited from Git
#error, #location_folder, #output
Instance Method Summary
collapse
Methods inherited from Git
#execute, #initialize, #success?
Instance Method Details
#author(author) ⇒ Object
52
53
54
55
|
# File 'lib/git_wrapper/commands/log.rb', line 52
def author(author)
@author = author
self
end
|
#command ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/git_wrapper/commands/log.rb', line 82
def command
command = "log -i --format=\"<log>#{xml_structure}</log>\""
command += " #{@commit}" if @commit
command += " --author \"#{@author}\"" if @author
command += " --since \"#{@since}\"" if @since
command += " --until \"#{@until}\"" if @until
command += " --grep \"#{@grep}\"" if @grep
command += " --skip #{@skip}" if @skip
command += " --max-count \"#{@max_count}\"" if @max_count
command += " #{@files.map{|f| "\"#{f}\"" }.join(' ')}" if @files
command
end
|
#commit(commit) ⇒ Object
47
48
49
50
|
# File 'lib/git_wrapper/commands/log.rb', line 47
def commit(commit)
@commit = commit
self
end
|
#files(files) ⇒ Object
42
43
44
45
|
# File 'lib/git_wrapper/commands/log.rb', line 42
def files(files)
@files = files.map{|f|to_relative_path(f)}
self
end
|
#grep(grep) ⇒ Object
57
58
59
60
|
# File 'lib/git_wrapper/commands/log.rb', line 57
def grep(grep)
@grep = grep
self
end
|
#max_count(max_count) ⇒ Object
77
78
79
80
|
# File 'lib/git_wrapper/commands/log.rb', line 77
def max_count(max_count)
@max_count = max_count
self
end
|
#result ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/git_wrapper/commands/log.rb', line 95
def result
return nil unless success?
results = []
if output
results = Nokogiri::XML("<logs>#{output}</logs>").xpath('logs/log').map do |element|
Results::LogInfo.new(Hash[*element.children.flat_map { |node| [node.name.to_sym, node.text] }])
end
end
@commit ? results.first : results
end
|
#since(date) ⇒ Object
62
63
64
65
|
# File 'lib/git_wrapper/commands/log.rb', line 62
def since(date)
@since = date
self
end
|
#skip(skip) ⇒ Object
72
73
74
75
|
# File 'lib/git_wrapper/commands/log.rb', line 72
def skip(skip)
@skip = skip
self
end
|
#until(date) ⇒ Object
67
68
69
70
|
# File 'lib/git_wrapper/commands/log.rb', line 67
def until(date)
@until = date
self
end
|