Added branch override for artifacts

This commit is contained in:
Michael Chen 2022-12-13 17:51:20 +01:00
parent 62c96fcbf6
commit 44bae3fa85
Signed by: cnml
GPG Key ID: 5845BF3F82D5F629
2 changed files with 7 additions and 1 deletions

View File

@ -219,6 +219,7 @@ class Artifact(TypedDict):
file: str
lines: NotRequired[list[int]]
repository: NotRequired[str]
branch: NotRequired[str]
RuleStatus = Literal["disregarded", "observed", "not applicable", "unknown"]
@ -258,6 +259,8 @@ properties:
type: string
repository:
type: string
branch:
type: string
lines:
type: array
items:
@ -311,7 +314,9 @@ rule_names = {
def artifact_to_string(info: ModelInformation, artifact: Artifact):
file = Path(artifact['file'])
filename = file.name
file_url = f"https://github.com/{artifact.get('repository', info['slug'])}/blob/{info.get('branch', 'master')}/{artifact['file']}"
project_branch = info.get("branch", "master")
branch = artifact.get("branch", project_branch)
file_url = f"https://github.com/{artifact.get('repository', info['slug'])}/blob/{branch}/{artifact['file']}"
lines = artifact.get("lines")
if lines is None:
return f"- {filename}: [File]({file_url})"

View File

@ -28,6 +28,7 @@
"additionalProperties": false,
"properties": {
"repository": { "type": "string" },
"branch": { "type": "string" },
"file": { "type": "string" },
"lines": { "type": "array", "items": { "type": "integer" } }
},