Class: Committer::GitHelper
- Inherits:
-
Object
- Object
- Committer::GitHelper
- Defined in:
- lib/committer/git_helper.rb
Overview
Helper class for git operations
Class Method Summary collapse
Class Method Details
.commit(summary, body = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/committer/git_helper.rb', line 9 def commit(summary, body = nil) if body system('git', 'commit', '-m', summary, '-m', body, '-e') else system('git', 'commit', '-m', summary, '-e') end end |
.repo_root ⇒ Object
17 18 19 |
# File 'lib/committer/git_helper.rb', line 17 def repo_root `git rev-parse --show-toplevel`.strip end |
.staged_diff ⇒ Object
21 22 23 24 25 26 |
# File 'lib/committer/git_helper.rb', line 21 def staged_diff stdout, stderr, status = Open3.capture3('git diff --staged') raise Committer::Error, "Failed to get git diff: #{stderr}" unless status.success? stdout.dup.force_encoding('UTF-8').scrub end |