Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
Enable gh-pages testing if explicitly added to .travis.yml
Browse files Browse the repository at this point in the history
This was requested in travis-ci/travis-ci#476.
  • Loading branch information
sarahhodne committed Nov 16, 2012
1 parent 657d6e2 commit 0b1bf72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/travis/model/request/approval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def accepted?
!repository.private? &&
!rails_fork? &&
!skipped? &&
!github_pages?
(github_pages_explicitly_enabled? || !github_pages?)
end

def approved?
Expand Down Expand Up @@ -48,6 +48,13 @@ def skipped?
commit.message.to_s =~ /\[ci(?: |:)([\w ]*)\]/i && $1.downcase == 'skip'
end

def github_pages_explicitly_enabled?
request.config &&
request.config['branches'] &&
request.config['branches']['only'] &&
request.config['branches']['only'].grep(/gh[-_]pages/i)
end

def github_pages?
commit.ref =~ /gh[-_]pages/i
end
Expand Down
6 changes: 6 additions & 0 deletions spec/travis/model/request/approval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
request.commit.stubs(:ref).returns('gh_pages')
approval.should_not be_accepted
end

it 'accepts a request that belongs to the github_pages branch and is explicitly set to build that branch' do
request.commit.stubs(:ref).returns('gh_pages')
request.stubs(:config).returns({'branches' => {'only' => ['gh_pages']}})
approval.should be_accepted
end
end

describe 'approved?' do
Expand Down

0 comments on commit 0b1bf72

Please sign in to comment.