Class: SafeUpdate::GitRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/safe_update/git_repo.rb

Instance Method Summary collapse

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(message)
  `git add Gemfile.lock`
  `git commit -m '#{message}'`
end

#discard_local_changesObject



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

Returns:

  • (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_checksObject



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

#pushObject



24
25
26
# File 'lib/safe_update/git_repo.rb', line 24

def push
  `git push`
end