diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-15 17:49:20 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-15 17:49:20 +0200 |
commit | 792a6ca79cbf262039bd4a84d0729412bd41e208 (patch) | |
tree | 17dda26877e415c8017d40b0a9447afd1c4ddf5c | |
parent | 4fc1a22b1707cf0a99d6843f5ff47a75e16eb964 (diff) | |
download | gitlab-ci-fix-skip-ci.tar.gz |
Prevent crash when push new branch with empty commits listfix-skip-ci
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/commit.rb | 20 |
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 |