summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-06-15 15:58:03 +0000
committerValery Sizov <valery@gitlab.com>2015-06-15 15:58:03 +0000
commit232a64426422d32780e893cdc6938d4def2181b7 (patch)
tree4a8ea7d77ab3a6b518f8fba3b68b0a2b3b83ffbb
parent5a5228dcbdc9fe53df93ea37851dd23e09c98682 (diff)
parent792a6ca79cbf262039bd4a84d0729412bd41e208 (diff)
downloadgitlab-ci-232a64426422d32780e893cdc6938d4def2181b7.tar.gz
Merge branch 'fix-skip-ci' into 'master'
Prevent crash when push new branch with empty commits list Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> See merge request !139
-rw-r--r--app/models/commit.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index f27a385..7cebf35 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -92,12 +92,12 @@ class Commit < ActiveRecord::Base
end
def create_builds
- return if push_data[:commits].last[:message] =~ /(\[ci skip\])/
+ return if skip_ci?
config_processor.builds_for_ref(ref, tag).each do |build_attrs|
builds.create!({
project: project,
- name: build_attrs[:name],
+ name: build_attrs[:name],
commands: build_attrs[:script],
tag_list: build_attrs[:tags]
})
@@ -119,12 +119,12 @@ class Commit < ActiveRecord::Base
end
def create_deploy_builds
- return if push_data[:commits].last[:message] =~ /(\[ci skip\])/
-
+ return if skip_ci?
+
config_processor.deploy_builds_for_ref(ref, tag).each do |build_attrs|
builds.create!({
project: project,
- name: build_attrs[:name],
+ name: build_attrs[:name],
commands: build_attrs[:script],
tag_list: build_attrs[:tags],
deploy: true
@@ -195,4 +195,14 @@ class Commit < ActiveRecord::Base
def config_processor
@config_processor ||= GitlabCiYamlProcessor.new(push_data[:ci_yaml_file])
end
+
+ def skip_ci?
+ commits = push_data[:commits]
+
+ if commits.present? && commits.last[:message] =~ /(\[ci skip\])/
+ true
+ else
+ false
+ end
+ end
end