Sha256: 2f14fc0264e5dc84b18e1dd85a41faa173a7fe231d5b26282388e5e33b0b2d0f

Contents?: true

Size: 692 Bytes

Versions: 3

Compression:

Stored size: 692 Bytes

Contents

require 'colorize'
require 'English'

module SafePusher
  class GithubRunner
    def push
      system('git push origin')

      exit_status = $CHILD_STATUS.exitstatus

      if exit_status == 128
        puts 'Syncing with github...'.green

        push_and_set_upstream

        exit_status = $CHILD_STATUS.exitstatus
      end

      exit_status
    end

    def open
      system(
        "open '#{SafePusher.configuration.repo_url}/pull/new/#{branch}'",
      )
    end

    private

    def push_and_set_upstream
      system("git push --set-upstream origin #{branch}")
    end

    def branch
      `git rev-parse --symbolic-full-name --abbrev-ref HEAD`.delete("\n")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
safe_pusher-0.4.0 lib/safe_pusher/github_runner.rb
safe_pusher-0.3.0 lib/safe_pusher/github_runner.rb
safe_pusher-0.2.2 lib/safe_pusher/github_runner.rb