Skip to content

Commit

Permalink
reject new pull requests that are not mergeable
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Aug 9, 2012
1 parent 8f4bd31 commit 8044e10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/travis/github/payload/pull_request.rb
Expand Up @@ -15,7 +15,11 @@ def event
end

def accept?
[:opened, :reopened].include?(action) || action == :synchronize && head_change?
case action
when :opened, :reopened then !!merge_commit
when :synchronize then head_change?
else false
end
end

def head_change?
Expand Down
5 changes: 5 additions & 0 deletions spec/travis/github/payload/pull_request_spec.rb
Expand Up @@ -12,6 +12,11 @@
it 'returns true' do
payload.accept?.should be_true
end

it 'rejects it if there is no merge commit' do
payload.event.data['pull_request']['merge_commit'] = nil
payload.should_not be_accept
end
end

describe 'given action is "reopened"' do
Expand Down

0 comments on commit 8044e10

Please sign in to comment.