mirror of
https://github.com/zhigang1992/boxen.git
synced 2026-01-12 17:12:46 +08:00
Move master? from Config to Checkout
It belongs with sha/changes/dirty?, and you know it.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user