Class: SafeUpdate::GitRepo
- Inherits:
-
Object
- Object
- SafeUpdate::GitRepo
- Defined in:
- lib/safe_update/git_repo.rb
Instance Method Summary collapse
- #commit_gemfile_lock(message) ⇒ Object
- #discard_local_changes ⇒ Object
- #gemfile_lock_has_changes? ⇒ Boolean
- #perform_safety_checks ⇒ Object
- #push ⇒ Object
Instance Method Details
#commit_gemfile_lock(message) ⇒ Object
19 20 21 22 |
# File 'lib/safe_update/git_repo.rb', line 19 def commit_gemfile_lock() `git add Gemfile.lock` `git commit -m '#{}'` end |
#discard_local_changes ⇒ Object
15 16 17 |
# File 'lib/safe_update/git_repo.rb', line 15 def discard_local_changes `git reset HEAD --hard` end |
#gemfile_lock_has_changes? ⇒ Boolean
28 29 30 31 |
# File 'lib/safe_update/git_repo.rb', line 28 def gemfile_lock_has_changes? result = `git diff --name-only` return result.include? 'Gemfile.lock' end |
#perform_safety_checks ⇒ Object
8 9 10 11 12 13 |
# File 'lib/safe_update/git_repo.rb', line 8 def perform_safety_checks check_for_staged_changes if gemfile_lock_has_changes? raise 'safe_update cannot run while there are uncommitted changes in Gemfile.lock' end end |
#push ⇒ Object
24 25 26 |
# File 'lib/safe_update/git_repo.rb', line 24 def push `git push` end |