Total Complexity | 5 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # SPDX-License-Identifier: LGPL-3.0-only |
||
2 | from doorstop import DoorstopInfo, DoorstopWarning, DoorstopError |
||
3 | from subprocess import check_output |
||
4 | from copy import copy |
||
5 | from random import random |
||
6 | |||
7 | |||
8 | def item_validator(item): |
||
9 | if getattr(item, "references") == None: |
||
10 | return [] |
||
11 | |||
12 | for ref in item.references: |
||
13 | if ref['sha'] != item._hash_reference(ref['path']): |
||
14 | yield DoorstopWarning("Hash has changed and it was not reviewed properly") |
||
15 | |||
16 | if 'modified' in ref['path']: |
||
17 | temp_item = copy(item) |
||
18 | current_value = item.is_reviewed() |
||
19 | check_output( |
||
20 | "echo '1111' > $(git rev-parse --show-toplevel)/reqs/ext/test-modified.file", shell=True) |
||
21 | temp_item.review() |
||
22 | next_value = item.is_reviewed() |
||
23 | check_output( |
||
24 | "echo '0000' > $(git rev-parse --show-toplevel)/reqs/ext/test-modified.file", shell=True) |
||
25 | |||
26 | yield DoorstopWarning(f"""This is a demonstration of a validator per folder identifying a external ref modified |
||
27 | without a proper review current SHA {current_value} modified SHA {next_value }. |
||
29 |