From 75624f5944dc066005b003f6d77b415aaac9ab31 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 10 Nov 2020 11:46:30 -0500 Subject: [PATCH 1/4] Automation Rules: allow to invert a match Ref https://github.com/readthedocs/readthedocs.org/pull/7653 Closes https://github.com/readthedocs/readthedocs.org/issues/6354 --- docs/automation-rules.rst | 12 ++++++--- readthedocs/builds/forms.py | 7 +++++ readthedocs/builds/managers.py | 6 ++--- .../migrations/0028_add_on_match_field.py | 18 +++++++++++++ readthedocs/builds/models.py | 10 ++++++- .../rtd_tests/tests/test_automation_rules.py | 26 +++++++++++++++++++ 6 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 readthedocs/builds/migrations/0028_add_on_match_field.py diff --git a/docs/automation-rules.rst b/docs/automation-rules.rst index e50b23293c9..eda692d3741 100644 --- a/docs/automation-rules.rst +++ b/docs/automation-rules.rst @@ -82,6 +82,12 @@ You can change the order using the up and down arrow buttons. New rules are added at the end (lower priority). +Perform action on match +----------------------- + +If this attribute is un-check, the rule will be inverted. +This means the action will be performed over versions that don't match the pattern. + Examples -------- @@ -127,9 +133,7 @@ Activate all new tags and branches that start with ``v`` or ``V`` Activate all new tags that don't contain the ``-nightly`` suffix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. TODO: update example if https://github.com/readthedocs/readthedocs.org/issues/6354 is approved. - - -- Custom match: ``.*(? Date: Wed, 11 Nov 2020 10:11:31 -0500 Subject: [PATCH 2/4] Update docs --- docs/automation-rules.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/automation-rules.rst b/docs/automation-rules.rst index eda692d3741..79efb61977a 100644 --- a/docs/automation-rules.rst +++ b/docs/automation-rules.rst @@ -85,8 +85,8 @@ You can change the order using the up and down arrow buttons. Perform action on match ----------------------- -If this attribute is un-check, the rule will be inverted. -This means the action will be performed over versions that don't match the pattern. +If this attribute is un-check, +the action will be performed over versions that don't match the pattern. Examples -------- From 7ea04d9bc67e3505787dbbbc0245f24b8a3d7fb2 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Wed, 6 Jan 2021 16:37:27 -0500 Subject: [PATCH 3/4] Update migration --- .../{0028_add_on_match_field.py => 0034_add_on_match_field.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename readthedocs/builds/migrations/{0028_add_on_match_field.py => 0034_add_on_match_field.py} (88%) diff --git a/readthedocs/builds/migrations/0028_add_on_match_field.py b/readthedocs/builds/migrations/0034_add_on_match_field.py similarity index 88% rename from readthedocs/builds/migrations/0028_add_on_match_field.py rename to readthedocs/builds/migrations/0034_add_on_match_field.py index b5cc0dc13b9..9056057e99d 100644 --- a/readthedocs/builds/migrations/0028_add_on_match_field.py +++ b/readthedocs/builds/migrations/0034_add_on_match_field.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('builds', '0027_add_privacy_level_automation_rules'), + ('builds', '0033_dont_cascade_delete_builds'), ] operations = [ From 668ceb62be0ec59362dca4e0deb85b737f613059 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Wed, 13 Jan 2021 11:10:24 -0500 Subject: [PATCH 4/4] Update test --- readthedocs/rtd_tests/tests/test_automation_rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/rtd_tests/tests/test_automation_rules.py b/readthedocs/rtd_tests/tests/test_automation_rules.py index c1abcbee6d2..ca60b90c6ca 100644 --- a/readthedocs/rtd_tests/tests/test_automation_rules.py +++ b/readthedocs/rtd_tests/tests/test_automation_rules.py @@ -97,7 +97,7 @@ def test_match( assert rule.matches.all().count() == (1 if result else 0) @pytest.mark.parametrize('type', [TAG, BRANCH]) - def test_not_match(self, type): + def test_not_match(self, trigger_build, type): version = get( Version, verbose_name='dont-match',