summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-06-05 14:23:42 +0300
committerValery Sizov <vsv2711@gmail.com>2015-06-05 14:23:42 +0300
commit70e9966639d7da9abc70e22814b3716eaca5d0c0 (patch)
treec45375da2c0c983c5e80cd9b5e89f809d8a368a0
parent06f586c8e85d100070745e8453bf9dc1b2528451 (diff)
downloadgitlab-ci-70e9966639d7da9abc70e22814b3716eaca5d0c0.tar.gz
Do not retry build for the same commit and ref
-rw-r--r--app/services/create_commit_service.rb2
-rw-r--r--spec/services/create_commit_service_spec.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/app/services/create_commit_service.rb b/app/services/create_commit_service.rb
index bcd7a63..81d552a 100644
--- a/app/services/create_commit_service.rb
+++ b/app/services/create_commit_service.rb
@@ -54,7 +54,7 @@ class CreateCommitService
commit = project.commits.create(data)
end
- commit.create_builds
+ commit.create_builds unless commit.builds.any?
if commit.builds.empty?
commit.create_deploy_builds
diff --git a/spec/services/create_commit_service_spec.rb b/spec/services/create_commit_service_spec.rb
index 4b4f788..ae118e4 100644
--- a/spec/services/create_commit_service_spec.rb
+++ b/spec/services/create_commit_service_spec.rb
@@ -97,5 +97,26 @@ describe CreateCommitService do
result.should be_persisted
end
end
+
+ it "skips build creation if there are already builds" do
+ commits = [{message: "message"}]
+ commit = service.execute(project,
+ ref: 'refs/heads/master',
+ before: '00000000',
+ after: '31das312',
+ commits: commits,
+ ci_yaml_file: gitlab_ci_yaml
+ )
+ commit.builds.count(:all).should == 2
+
+ commit = service.execute(project,
+ ref: 'refs/heads/master',
+ before: '00000000',
+ after: '31das312',
+ commits: commits,
+ ci_yaml_file: gitlab_ci_yaml
+ )
+ commit.builds.count(:all).should == 2
+ end
end
end