Skip to content

Commit a037336

Browse files
πŸ‘Œ Exclude external needs from needs_id_regex check (#1108)
fix for [#1099](#1099) --------- Co-authored-by: Chris Sewell <[email protected]>
1 parent cf5598f commit a037336

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea
2+
*.iml
3+
.DS_Store
24
.venv*
35
.pvenv
46
.nox

β€Ždocs/changelog.rstβ€Ž

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ License
99
.. include:: ../LICENSE
1010

1111

12+
Unreleased
13+
----------
14+
15+
Fixed
16+
.....
17+
18+
* Fix external needs identifier checked by regex (`#1099 <https://github.com/useblocks/sphinx-needs/pull/1099>`_)
19+
20+
1221
2.0.0
1322
-----
1423

β€Žsphinx_needs/api/need.pyβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ def run():
196196
else:
197197
need_id = id
198198

199-
if needs_config.id_regex and not re.match(needs_config.id_regex, need_id):
199+
if (
200+
needs_config.id_regex
201+
and not is_external
202+
and not re.match(needs_config.id_regex, need_id)
203+
):
200204
raise NeedsInvalidException(
201205
f"Given ID '{need_id}' does not match configured regex '{needs_config.id_regex}'"
202206
)

β€Žtests/doc_test/doc_needs_external_needs/conf.pyβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@
4848
"id_prefix": "ext_rel_path_",
4949
},
5050
]
51+
52+
# we want to ensure only internal needs are checked against this regex, not the external ones
53+
needs_id_regex = "INTERNAL.*"

β€Žtests/doc_test/doc_needs_external_needs/index.rstβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
TEST DOCUMENT NEEDS EXTERNAL NEEDS
22
==================================
33

4+
.. spec:: Internal need
5+
:id: INTERNAL_001
6+
7+
An internal requirement with an id check by the regex. External needs identifiers shall not be checked for regex matching.
8+
49
.. needlist::
510
:tags: ext_test
611

0 commit comments

Comments
Β (0)