Class: Capistrano::Slacky::Command::Diff
- Inherits:
-
Object
- Object
- Capistrano::Slacky::Command::Diff
- Defined in:
- lib/capistrano/slacky/command/diff.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(previous:, current:) ⇒ Diff
constructor
A new instance of Diff.
Constructor Details
#initialize(previous:, current:) ⇒ Diff
Returns a new instance of Diff.
17 18 19 20 |
# File 'lib/capistrano/slacky/command/diff.rb', line 17 def initialize(previous:, current:) @previous = previous @current = current end |
Class Method Details
.call(previous:, current:) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/capistrano/slacky/command/diff.rb', line 7 def self.call(previous:, current:) output = nil ::Capistrano::Slacky.on(within: :repository) do output = new(previous: previous, current: current).call end output end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/capistrano/slacky/command/diff.rb', line 22 def call log = ::SSHKit::Backend.current.capture( :git, :log, "--oneline", "--first-parent", "#{previous}..#{current}" ).split("\n") log.reverse.map.with_index(1) do |line, index| sha, commit = line.match(/^(\w+) (.*+?)/).captures if /^Merge pull request/.match?(commit) commit = ::SSHKit::Backend.current.capture(:git, :log, "-1", sha, '--pretty=format:"%b"') end Message.new(index: index, sha: sha, commit: commit) end end |