Sha256: a9508bcad87142f081e70a5d43c4cff11c83a0bf9b16ec6f7e96d98170058157

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

require 'colorize'
require 'English'

module SafePusher
  class GithubRunner
    def push_and_open
      push

      exit_status = $CHILD_STATUS.exitstatus

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

        push_and_set_upstream

        exit_status = $CHILD_STATUS.exitstatus

        open if exit_status == 0
      end

      exit_status
    end

    def push
      system('git push origin')
    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

2 entries across 2 versions & 1 rubygems

Version Path
safe_pusher-0.2.1 lib/safe_pusher/github_runner.rb
safe_pusher-0.2.0 lib/safe_pusher/github_runner.rb