Class: Jeny::StateManager::Git
- Inherits:
-
Jeny::StateManager
- Object
- Jeny::StateManager
- Jeny::StateManager::Git
- Defined in:
- lib/jeny/state_manager/git.rb
Overview
StateManager implementation that uses git to manage state management.
This state management requires executing jeny in the git root folder.
Instance Attribute Summary
Attributes inherited from Jeny::StateManager
Instance Method Summary collapse
-
#commit(changed, state) ⇒ Object
Commits all changes, using ‘git add` the `git commit`.
-
#reset(changed, state) ⇒ Object
Reset all changes through a ‘git reset –hard`.
-
#stash(state) ⇒ Object
Executes a ‘git stash`.
-
#unstash(state) ⇒ Object
Executes a ‘git stash pop`.
Methods inherited from Jeny::StateManager
Constructor Details
This class inherits a constructor from Jeny::StateManager
Instance Method Details
#commit(changed, state) ⇒ Object
Commits all changes, using ‘git add` the `git commit`
30 31 32 33 34 35 |
# File 'lib/jeny/state_manager/git.rb', line 30 def commit(changed, state) return if changed.empty? system("git add #{changed.join(" ")}") msg = "jeny #{$*.join(' ')}" system("git commit -m '#{msg}'") end |
#reset(changed, state) ⇒ Object
Reset all changes through a ‘git reset –hard`.
WARN: changes not related to ‘changed` are reverted too, which should be nothing since a stash has been done before.
24 25 26 27 |
# File 'lib/jeny/state_manager/git.rb', line 24 def reset(changed, state) changed.each{|f| f.rm_rf if f.exists? } system("git reset --hard") end |
#stash(state) ⇒ Object
Executes a ‘git stash`
9 10 11 12 13 |
# File 'lib/jeny/state_manager/git.rb', line 9 def stash(state) system("git diff --exit-code") state.stashed = ($?.exitstatus != 0) system("git stash") if state.stashed end |
#unstash(state) ⇒ Object
Executes a ‘git stash pop`
16 17 18 |
# File 'lib/jeny/state_manager/git.rb', line 16 def unstash(state) system("git stash pop") if state.stashed end |