Move master? from Config to Checkout

It belongs with sha/changes/dirty?, and you know it.
This commit is contained in:
Yossef Mendelssohn
2012-10-05 02:04:17 -04:00
parent 988c9803bb
commit e1a5da7a55
3 changed files with 12 additions and 6 deletions

View File

@@ -10,6 +10,10 @@ module Boxen
Dir.chdir(config.repodir) { `git rev-parse HEAD`.strip }
end
def master?
Dir.chdir(config.repodir) { `git symbolic-ref HEAD`.strip == 'refs/heads/master' }
end
def dirty?
!changes.empty?
end

View File

@@ -148,12 +148,6 @@ module Boxen
@login = login
end
# Is Boxen running on the `master` branch?
def master?
`git symbolic-ref HEAD`.chomp == "refs/heads/master"
end
# A GitHub user's profile name.
attr_accessor :name

View File

@@ -18,6 +18,14 @@ class BoxenCheckoutTest < Boxen::Test
assert_equal sha, @checkout.sha
end
def test_master?
@checkout.stubs(:"`").with("git symbolic-ref HEAD").returns("refs/heads/topic\n")
assert !@checkout.master?
@checkout.stubs(:"`").with("git symbolic-ref HEAD").returns("refs/heads/master\n")
assert @checkout.master?
end
def test_changes
changes = ' maybe a bunch of stuff happened '
@checkout.expects(:"`").with("git status --porcelain").returns(changes)