Class: GitOops::Commands::ResetCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/git_oops/commands/reset_command.rb

Constant Summary collapse

DEFAULT_LOG_LIMIT =
5

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ResetCommand

Returns a new instance of ResetCommand.



11
12
13
14
15
# File 'lib/git_oops/commands/reset_command.rb', line 11

def initialize(options)
  @options = options
  @prompt = TTY::Prompt.new
  @pastel = Pastel.new
end

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/git_oops/commands/reset_command.rb', line 17

def execute
  display_current_log
  puts "\n#{@pastel.blue('')} Above is your current git log. Below are all available commits from git reflog:\n\n"

  commits = fetch_commits
  return if commits.empty?

  begin
    selected_commit = select_commit(commits)
    return unless selected_commit

    handle_restore(selected_commit)
  rescue TTY::Reader::InputInterrupt
    puts "\n#{@pastel.blue('')} Operation cancelled. No changes were made."
    exit 0
  end
end