Class: Rralph::Git
- Inherits:
-
Object
- Object
- Rralph::Git
- Defined in:
- lib/rralph/git.rb
Instance Method Summary collapse
- #commit_changes(message) ⇒ Object
- #has_changes? ⇒ Boolean
- #in_git_repo? ⇒ Boolean
-
#initialize ⇒ Git
constructor
A new instance of Git.
- #status ⇒ Object
Constructor Details
#initialize ⇒ Git
Returns a new instance of Git.
5 |
# File 'lib/rralph/git.rb', line 5 def initialize; end |
Instance Method Details
#commit_changes(message) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rralph/git.rb', line 12 def commit_changes() add_result = `git add . 2>&1` raise GitError, "Failed to stage files: #{add_result}" unless $?.success? commit_result = `git commit -m #{.shellescape} 2>&1` raise GitError, "Failed to commit: #{commit_result}" unless $?.success? `git rev-parse --short HEAD 2>/dev/null`.strip end |
#has_changes? ⇒ Boolean
26 27 28 29 |
# File 'lib/rralph/git.rb', line 26 def has_changes? status = `git status --porcelain 2>/dev/null` !status.empty? end |
#in_git_repo? ⇒ Boolean
7 8 9 10 |
# File 'lib/rralph/git.rb', line 7 def in_git_repo? `git rev-parse --git-dir 2>/dev/null` $?.success? end |
#status ⇒ Object
22 23 24 |
# File 'lib/rralph/git.rb', line 22 def status `git status --short 2>/dev/null` end |