diff --git a/lib/travis/model/request/approval.rb b/lib/travis/model/request/approval.rb index a7dab1737..6f0678aac 100644 --- a/lib/travis/model/request/approval.rb +++ b/lib/travis/model/request/approval.rb @@ -13,7 +13,7 @@ def accepted? !repository.private? && (!excluded_repository? || included_repository?) && !skipped? && - !github_pages? + (github_pages_explicitly_enabled? || !github_pages?) end def approved? @@ -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 diff --git a/spec/travis/model/request/approval_spec.rb b/spec/travis/model/request/approval_spec.rb index 2e07fac9c..31e3bd6a7 100644 --- a/spec/travis/model/request/approval_spec.rb +++ b/spec/travis/model/request/approval_spec.rb @@ -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