Method: RokuBuilder::Stager#unstage

Defined in:
lib/roku_builder/stager.rb

#unstageBoolean

Revert the change that the stage method made

Returns:

  • (Boolean)

    whether the revert was successful or not



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/roku_builder/stager.rb', line 62

def unstage
  @orginal_directory ||= Dir.pwd
  unstage_success = true
  case @method
  when :current, :in, :working
    # Do Nothing
  when :git
    switch_directory
    begin
      git_switch_from(branch: @ref, checkout: @stage_success)
    rescue Git::GitExecuteError
      git_rescue
      unstage_success = false
    end
    switch_directory_back
  when :script
    switch_directory
    if @scripts[:unstage]
      unstaging_logs = RokuBuilder.system(command: @scripts[:unstage])
      if !unstaging_logs.empty?
        @logger.warn "===== Unstaging Logs Start ====="
        puts unstaging_logs
        @logger.warn "===== Unstaging Logs End ======="
      end
    end
    switch_directory_back
  when :plugin
    @plugin.unstage(options: @options)
  end
  RokuBuilder.process_hook(hook: "post_unstage", params: {config: @config, options: @options})
  unstage_success
end