summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-08 07:28:26 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-08 07:28:26 +0000
commitb55d8c02fade229327c3347472125a0705fafeea (patch)
tree1c2d2252655d36e674519f4c63bf00a0a476a49e
parent10c1ce31035539e0c87ae6439937ada230285b49 (diff)
parent95a081317df12302baa6873749bb0b435062edb2 (diff)
downloadgitlab-ci-b55d8c02fade229327c3347472125a0705fafeea.tar.gz
Merge branch 'commit_creation_fix' into 'master'
Fix builds retrying when we remove commit from branch and push it again https://dev.gitlab.org/gitlab/gitlab-ci/issues/255 See merge request !124
-rw-r--r--CHANGELOG1
-rw-r--r--app/services/create_commit_service.rb2
-rw-r--r--spec/services/create_commit_service_spec.rb21
3 files changed, 23 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index dcaca23..aeab8f8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@ v7.12.0
- Using .gitlab-ci.yml file instead of jobs
- Link to the runner from the build page for admin user
- Ability to set secret variables for runner
+ - Dont retry build when push same commit in same ref twice
v7.11.0
- Deploy Jobs API calls
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