Sha256: 5f68dbfb73d94ae317269ae4721fc06d49f72344f53f94cbb4e86d2aa1ad6f63

Contents?: true

Size: 896 Bytes

Versions: 5

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

require 'git'
require 'logger'

module LearnTest
  module GitWip
    class << self
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
learn-test-3.2.4 lib/learn_test/git_wip.rb
learn-test-3.2.3 lib/learn_test/git_wip.rb
learn-test-3.2.2 lib/learn_test/git_wip.rb
learn-test-3.2.1 lib/learn_test/git_wip.rb
learn-test-3.2.1.pre.7 lib/learn_test/git_wip.rb