Class: Matheus::QuickCommit

Inherits:
Command
  • Object
show all
Defined in:
lib/matheus/quick_commit.rb

Instance Method Summary collapse

Methods inherited from Command

call

Methods included from StringFormat

#bold, #error, #red

Methods included from Result::Methods

#Failure, #Success

Instance Method Details

#callObject

Usage:

$ quick-commit


5
6
7
8
9
10
11
12
# File 'lib/matheus/quick_commit.rb', line 5

def call(*)
  diff = `git diff --cached`
  return Failure("No changes to commit.") if diff.blank?

  Q.call(["Please write a good one-line commit message for the following diff. Return only plain-text. Diff:\n#{diff}"], skip_cache: true)
    .on_success { |msg| confirm("Accept commit message?", return_value: msg) }
    .on_success { |commit_message| system(%(git commit -m "#{commit_message}"), out: :close) }
end