Merge "Don't take into account commit message for skip-if filter"
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index be9570c..39765ba 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -765,7 +765,10 @@
expressions.
The pattern for '/COMMIT_MSG' is always matched on and does not
- have to be included.
+ have to be included. Exception is merge commits (without modified
+ files), in this case '/COMMIT_MSG' is not matched, and job is not
+ skipped. In case of merge commits it's assumed that list of modified
+ files isn't predictible and CI should be run.
**voting (optional)**
Boolean value (``true`` or ``false``) that indicates whatever
diff --git a/tests/test_change_matcher.py b/tests/test_change_matcher.py
index 1f4ab93..0585322 100644
--- a/tests/test_change_matcher.py
+++ b/tests/test_change_matcher.py
@@ -123,13 +123,13 @@
self._test_matches(False)
def test_matches_returns_false_when_not_all_files_match(self):
- self._test_matches(False, files=['docs/foo', 'foo/bar'])
+ self._test_matches(False, files=['/COMMIT_MSG', 'docs/foo', 'foo/bar'])
- def test_matches_returns_true_when_commit_message_matches(self):
- self._test_matches(True, files=['/COMMIT_MSG'])
+ def test_matches_returns_false_when_commit_message_matches(self):
+ self._test_matches(False, files=['/COMMIT_MSG'])
def test_matches_returns_true_when_all_files_match(self):
- self._test_matches(True, files=['docs/foo'])
+ self._test_matches(True, files=['/COMMIT_MSG', 'docs/foo'])
class TestMatchAll(BaseTestMatcher):
diff --git a/tests/test_model.py b/tests/test_model.py
index ac19383..6ad0750 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -36,12 +36,12 @@
def test_change_matches_returns_false_for_matched_skip_if(self):
change = model.Change('project')
- change.files = ['docs/foo']
+ change.files = ['/COMMIT_MSG', 'docs/foo']
self.assertFalse(self.job.changeMatches(change))
def test_change_matches_returns_true_for_unmatched_skip_if(self):
change = model.Change('project')
- change.files = ['foo']
+ change.files = ['/COMMIT_MSG', 'foo']
self.assertTrue(self.job.changeMatches(change))
def test_copy_retains_skip_if(self):
diff --git a/zuul/change_matcher.py b/zuul/change_matcher.py
index ed380f0..ca2d93f 100644
--- a/zuul/change_matcher.py
+++ b/zuul/change_matcher.py
@@ -101,7 +101,7 @@
yield self.commit_regex
def matches(self, change):
- if not (hasattr(change, 'files') and change.files):
+ if not (hasattr(change, 'files') and len(change.files) > 1):
return False
for file_ in change.files:
matched_file = False