[refs #90] add already state

This commit is contained in:
Alexander Machehin 2012-04-20 22:23:28 +06:00
parent a37bf7b50a
commit 598c072a80
2 changed files with 12 additions and 4 deletions

View File

@ -17,6 +17,10 @@ class PullRequest < Issue
transition [:open, :ready] => :blocked transition [:open, :ready] => :blocked
end end
event :already do
transition [:open, :blocked, :ready] => :already
end
event :merging do event :merging do
transition :ready => :merged transition :ready => :merged
end end
@ -35,7 +39,10 @@ class PullRequest < Issue
end end
def check def check
if ret = merge #FIXME already up-to-date... ret = merge
if ret =~ /Already up-to-date/
already
elsif ret =~ /Merge made by recursive/
system("cd #{path} && git reset --hard HEAD^") # remove merge commit system("cd #{path} && git reset --hard HEAD^") # remove merge commit
ready ready
else else
@ -68,7 +75,7 @@ class PullRequest < Issue
def merge def merge
clone clone
system("cd #{path} && git checkout #{data[:base_branch]} && git merge --no-ff #{data[:head_branch]}") %x(cd #{path} && git checkout #{data[:base_branch]} && git merge --no-ff #{data[:head_branch]}) #FIXME need sanitize branch name!
end end
def clone def clone
@ -80,7 +87,8 @@ class PullRequest < Issue
end end
Dir.chdir(path) do Dir.chdir(path) do
[data[:base_branch], data[:head_branch]].each do |branch| [data[:base_branch], data[:head_branch]].each do |branch|
system "git checkout #{branch} && git pull origin #{branch}" system 'git', 'checkout', branch
system 'git', 'pull', 'origin', branch
end end
end end
# TODO catch errors # TODO catch errors

View File

@ -40,7 +40,7 @@ describe PullRequest do
it 'should not be merged when already up-to-date branches' do it 'should not be merged when already up-to-date branches' do
@pull.data[:head_branch] = 'master' @pull.data[:head_branch] = 'master'
@pull.check @pull.check
@pull.state.should == 'blocked' # FIXME @pull.state.should == 'already'
end end
end end