Class: Mushy::GitLog
Instance Attribute Summary
Attributes inherited from Flux
#config, #flow, #id, #masher, #parent_fluxs, #subscribed_to, #type
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Flux
#convert_this_to_an_array, #convert_to_symbolized_hash, #execute, #execute_single_event, #group_these_results, #guard, #ignore_these_results, inherited, #initialize, #join_these_results, #limit_these_results, #merge_these_results, #model_these_results, #outgoing_split_these_results, #shape_these, #sort_these_results, #standardize_these
Constructor Details
This class inherits a constructor from Mushy::Flux
Class Method Details
.details ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mushy/fluxs/git_log.rb', line 5 def self.details { name: 'GitLog', description: 'Return git logs.', config: { directory: { description: 'The working directory in which the command will be run.', type: 'text', shrink: true, value: '', }, after: { description: 'Filter for commits after this', type: 'text', shrink: true, value: '', }, before: { description: 'Filter for commits before this', type: 'text', shrink: true, value: '', }, author: { description: 'Filter for commits by this author', type: 'text', shrink: true, value: '', }, committer: { description: 'Filter for commits by this committer', type: 'text', shrink: true, value: '', }, }, } end |
Instance Method Details
#process(event, config) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mushy/fluxs/git_log.rb', line 44 def process event, config config[:command] = 'git log' if config[:directory].to_s != '' config[:command] = "cd \"#{config[:directory]}\";#{config[:command]}" end [:after, :before, :author, :committer] .select { |x| config[x].to_s != ''} .each { |k| config[:command] = "#{config[:command]} --#{k}=\"#{config[k]}\"" } result = super event, config return result unless result[:success] result[:text].split("\n\n").reduce([]) do |results, line| if line.start_with? 'commit' results << { message: line.sub('commit', 'commit:') } else results[-1][:message] = results[-1][:message] + "\nMessage: " + line.strip end results end.map { |x| x[:message] }.map do |line| line.split("\n").reduce({}) do |t, i| segments = i.split ':' key = segments.shift.strip.downcase.to_sym t[key] = segments.map { |y| y.strip }.join ':' t end end.map do |commit| commit.tap do |x| segments = x[:author].split '<' x[:author_name] = segments.shift.strip x[:author_email] = segments.join('').strip.gsub('>', '') end end end |