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

Commit

Permalink
Merge pull request #137 from henrikhodne/enable-testing-of-gh-pages
Browse files Browse the repository at this point in the history
Enable gh-pages testing if explicitly added to .travis.yml
  • Loading branch information
joshk committed Dec 11, 2012
2 parents 707a3b0 + 0b1bf72 commit 2804d04
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? &&
(!excluded_repository? || included_repository?) &&
!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

3 comments on commit 2804d04

@svenfuchs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this tested on staging?

i'm seeing:

undefined method `grep' for "master":String                                                           
/app/vendor/bundle/jruby/1.9/bundler/gems/travis-core-fff402c2c172/lib/travis/model/request/approval.rb:52:in `github_pages_explicitly_enabled?'
/app/vendor/bundle/jruby/1.9/bundler/gems/travis-core-fff402c2c172/lib/travis/model/request/approval.rb:16:in `accepted?'

branches: only can also be a single string

@sarahhodne
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently it wasn't. Pull request on the way.

@svenfuchs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already fixed, buddy

Please sign in to comment.