Sha256: a4a2ac36adac10b47d7a92e1f114345f27cc3d5099a4331ac22e513292e9414d

Contents?: true

Size: 1.62 KB

Versions: 10

Compression:

Stored size: 1.62 KB

Contents

module BardGit
  private
    def ensure_integration_branch!
      return if `git name-rev --name-only HEAD`.chomp == "integration"
      fatal "You are not on the integration branch! Type `git checkout integration` to switch to it. If you have made changes to your current branch, please see Micah for assistance."
    end

    def ensure_clean_working_directory!
      return if`git status`.include? "working directory clean"
      fatal "Cannot upload changes: You have uncommitted changes!\n  Please run git commit before attempting to push or pull."
    end

    def fast_forward_merge? 
      run_crucial "git fetch origin"
      head = run_crucial "git rev-parse HEAD"
      remote_head = run_crucial "git rev-parse origin/integration"
      @common_ancestor = find_common_ancestor head, remote_head
      @common_ancestor == remote_head
    end

    def find_common_ancestor(head1, head2)
      run_crucial "git merge-base #{head1} #{head2}"
    end

    def submodule_dirty?
      @repo ||= Grit::Repo.new "."
      submodules = Grit::Submodule.config(@repo, @repo.head.name)
      submodules.any? do |name, submodule|
        Dir.chdir submodule["path"] do
          not `git status`.include? "working directory clean"
        end
      end
    end

    def submodule_unpushed?
      @repo ||= Grit::Repo.new "."
      submodules = Grit::Submodule.config(@repo, @repo.head.name)
      submodules.any? do |name, submodule|
        Dir.chdir submodule["path"] do
          branch = `git name-rev --name-only HEAD`.chomp
          `git fetch origin`
          submodule["id"] != `git rev-parse origin/#{branch}`.chomp
        end
      end
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bard-0.5.8 lib/bard/git.rb
bard-0.5.7 lib/bard/git.rb
bard-0.5.6 lib/bard/git.rb
bard-0.5.5 lib/bard/git.rb
bard-0.5.4 lib/bard/git.rb
bard-0.5.3 lib/bard/git.rb
bard-0.5.2 lib/bard/git.rb
bard-0.5.1 lib/bard/git.rb
bard-0.5.0 lib/bard/git.rb
bard-0.4.0 lib/bard/git.rb