From 4df9ea86c2c1603675cdf3a8a543a2b356082e25 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 7 Apr 2021 12:37:28 -0400 Subject: [PATCH] ansible-test - change diff mathching regexp so prefixes are optional The `a/` and `b/` prefixes can be disabled in the `git diff` output by setting `diff.noprefix` to `true`. The output is still a valid diff, but `ansible-test` would raise an exception since without the prefixes, it thought the diff line was invalid. --- changelogs/fragments/ansible-test-diff-prefix-optional.yml | 4 ++++ test/lib/ansible_test/_internal/diff.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/ansible-test-diff-prefix-optional.yml diff --git a/changelogs/fragments/ansible-test-diff-prefix-optional.yml b/changelogs/fragments/ansible-test-diff-prefix-optional.yml new file mode 100644 index 00000000000..2394965328d --- /dev/null +++ b/changelogs/fragments/ansible-test-diff-prefix-optional.yml @@ -0,0 +1,4 @@ +bugfixes: + - >- + ansible-test - make the ``a/`` and ``b/`` prefixes an optional match + since these can be turned off with the ``diff.noprefix`` setting in ``git`` diff --git a/test/lib/ansible_test/_internal/diff.py b/test/lib/ansible_test/_internal/diff.py index 1e2038b98be..5671ec7f280 100644 --- a/test/lib/ansible_test/_internal/diff.py +++ b/test/lib/ansible_test/_internal/diff.py @@ -180,7 +180,7 @@ class DiffParser: """Process a diff start line.""" self.complete_file() - match = re.search(r'^diff --git "?a/(?P.*)"? "?b/(?P.*)"?$', self.line) + match = re.search(r'^diff --git "?(?:a/)?(?P.*)"? "?(?:b/)?(?P.*)"?$', self.line) if not match: raise Exception('Unexpected diff start line.')