-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Insert an example using custom validator and sha
- Loading branch information
Showing
6 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
settings: | ||
digits: 3 | ||
itemformat: yaml | ||
parent: REQ | ||
prefix: EXT | ||
sep: "" | ||
extensions: | ||
item_validator: .req_sha_item_validator.py | ||
item_sha_required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# SPDX-License-Identifier: LGPL-3.0-only | ||
from doorstop import DoorstopInfo, DoorstopWarning, DoorstopError | ||
from subprocess import check_output | ||
from copy import copy | ||
from random import random | ||
|
||
|
||
def item_validator(item): | ||
if getattr(item, "references") == None: | ||
return [] | ||
|
||
for ref in item.references: | ||
if ref['sha'] != item._hash_reference(ref['path']): | ||
yield DoorstopWarning("Hash has changed and it was not reviewed properly") | ||
|
||
if 'modified' in ref['path']: | ||
temp_item = copy(item) | ||
current_value = item.is_reviewed() | ||
check_output( | ||
"echo '1111' > $(git rev-parse --show-toplevel)/reqs/ext/test-modified.file", shell=True) | ||
temp_item.review() | ||
next_value = item.is_reviewed() | ||
check_output( | ||
"echo '0000' > $(git rev-parse --show-toplevel)/reqs/ext/test-modified.file", shell=True) | ||
|
||
yield DoorstopWarning(f"""This is a demonstration of a validator per folder identifying a external ref modified | ||
without a proper review current SHA {current_value} modified SHA {next_value }. | ||
Result: { next_value == current_value} """) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
active: true | ||
derived: false | ||
header: '' | ||
level: 1.0 | ||
links: [] | ||
normative: true | ||
ref: '' | ||
references: | ||
- path: reqs/ext/test.file | ||
sha: 24d9b35c727e6c78676c2ad378a8c3c47cfb539f3583d3cd9e1eafee51d5679d | ||
type: file | ||
reviewed: n0xxAj0z-SqNcebKEu8p9HDE8jAs5I8Vz4kX-5ZieA4= | ||
text: | | ||
Test where we calculate the SHA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
active: true | ||
derived: false | ||
header: '' | ||
level: 2.0 | ||
links: [] | ||
normative: true | ||
ref: '' | ||
references: | ||
- path: reqs/ext/test-modified.file | ||
sha: 49ca5d81054fdd20572294b9350b605d05e0df91da09a46fb8bde7fd6c1c172d | ||
type: file | ||
reviewed: arLWz1tqET94t2j7FG0ncvKpwGe5twDi-jPbBnikxho= | ||
text: | | ||
Test where we calculate the SHA, file modified during evaluation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0001 |