Sha256: d5656f87f919e2479a13c4188a0f49e14f031ed98c8e5824468cc6b0442d26d3

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

module YSI
  class Git
    def initialize(working_dir = Dir.pwd)
      @working_dir = working_dir
    end

    def run_git(args)
      Dir.chdir(@working_dir) do
        `git #{args}`
      end
    end

    def origin
      run_git("remote -v").match(/origin\s+(.*?)(\.git)?\s+\(push\)/)[1]
    end

    def needs_push?
      local_master = run_git("rev-parse master")
      remote_master = run_git("rev-parse origin/master")
      base = run_git("merge-base master origin/master")

      remote_master == base && local_master != remote_master
    end

    def push
      `git push`
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yes_ship_it-0.0.5 lib/yes_ship_it/git.rb