Commit 52795c40 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'update-ci-skip-regex-to-accept-underscores-and-hyphens' into 'master'

updated ci skip regex to accept underscores and hyphens

See merge request !9130
parents 972b77f7 ad88cf3e
......@@ -59,7 +59,8 @@ module Ci
private
def skip_ci?
pipeline.git_commit_message =~ /\[(ci skip|skip ci)\]/i if pipeline.git_commit_message
return false unless pipeline.git_commit_message
pipeline.git_commit_message =~ /\[(ci[ _-]skip|skip[ _-]ci)\]/i
end
def commit
......
......@@ -79,16 +79,25 @@ describe Ci::CreatePipelineService, services: true do
context 'when commit contains a [ci skip] directive' do
let(:message) { "some message[ci skip]" }
let(:messageFlip) { "some message[skip ci]" }
let(:capMessage) { "some message[CI SKIP]" }
let(:capMessageFlip) { "some message[SKIP CI]" }
ci_messages = [
"some message[ci skip]",
"some message[skip ci]",
"some message[CI SKIP]",
"some message[SKIP CI]",
"some message[ci_skip]",
"some message[skip_ci]",
"some message[ci-skip]",
"some message[skip-ci]"
]
before do
allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { message }
end
it "skips builds creation if there is [ci skip] tag in commit message" do
commits = [{ message: message }]
ci_messages.each do |ci_message|
it "skips builds creation if the commit message is #{ci_message}" do
commits = [{ message: ci_message }]
pipeline = execute(ref: 'refs/heads/master',
before: '00000000',
after: project.commit.id,
......@@ -98,47 +107,25 @@ describe Ci::CreatePipelineService, services: true do
expect(pipeline.builds.any?).to be false
expect(pipeline.status).to eq("skipped")
end
it "skips builds creation if there is [skip ci] tag in commit message" do
commits = [{ message: messageFlip }]
pipeline = execute(ref: 'refs/heads/master',
before: '00000000',
after: project.commit.id,
commits: commits)
expect(pipeline).to be_persisted
expect(pipeline.builds.any?).to be false
expect(pipeline.status).to eq("skipped")
end
it "skips builds creation if there is [CI SKIP] tag in commit message" do
commits = [{ message: capMessage }]
pipeline = execute(ref: 'refs/heads/master',
before: '00000000',
after: project.commit.id,
commits: commits)
expect(pipeline).to be_persisted
expect(pipeline.builds.any?).to be false
expect(pipeline.status).to eq("skipped")
end
it "does not skips builds creation if there is no [ci skip] or [skip ci] tag in commit message" do
allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { "some message" }
it "skips builds creation if there is [SKIP CI] tag in commit message" do
commits = [{ message: capMessageFlip }]
commits = [{ message: "some message" }]
pipeline = execute(ref: 'refs/heads/master',
before: '00000000',
after: project.commit.id,
commits: commits)
expect(pipeline).to be_persisted
expect(pipeline.builds.any?).to be false
expect(pipeline.status).to eq("skipped")
expect(pipeline.builds.first.name).to eq("rspec")
end
it "does not skips builds creation if there is no [ci skip] or [skip ci] tag in commit message" do
allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { "some message" }
it "does not skip builds creation if the commit message is nil" do
allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { nil }
commits = [{ message: "some message" }]
commits = [{ message: nil }]
pipeline = execute(ref: 'refs/heads/master',
before: '00000000',
after: project.commit.id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment