Module: LearnTest::GitWip

Defined in:
lib/learn_test/git_wip.rb

Class Method Summary collapse

Class Method Details

.run!(log: false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/learn_test/git_wip.rb', line 9

def run!(log: false)
  git = Git.open('./', log: log)
  working_branch = git.current_branch

  commands = [
    'learn-test-wip save "Automatic test submission" --editor',
    "git push origin wip/#{working_branch}:refs/heads/wip"
  ].join(';')

  Open3.popen3(commands) do |_stdin, _stdout, _stderr, wait_thr|
    # while out = stdout.gets do; puts out; end
    # while err = stderr.gets do; puts err; end
  
    if wait_thr.value.exitstatus.zero?
      git.config['remote.origin.url'].gsub('.git', '/tree/wip')
    else
      #  puts 'There was an error running learn-test-wip'
      false
    end
  end
rescue StandardError => e
  false
end