Skip to content

Commit 1a0783d

Browse files
committed
Convert common attributes
1 parent 4dc6103 commit 1a0783d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sonar/util/portfolio_helper.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121

2222
from typing import Any
2323
from sonar import utilities as util
24+
from sonar.util import common_json_helper
2425

2526

2627
def convert_portfolio_json(old_json: dict[str, Any]) -> dict[str, Any]:
2728
"""Converts the sonar-config old JSON report format for a single portfolio to the new one"""
28-
new_json = old_json.copy()
29+
new_json = common_json_helper.convert_common_fields(old_json.copy())
30+
if "projects" in new_json:
31+
new_json["projects"] = common_json_helper.convert_common_fields(new_json["projects"])
2932
for key in "children", "portfolios":
3033
if key in new_json:
3134
new_json[key] = convert_portfolios_json(new_json[key])
@@ -38,7 +41,6 @@ def convert_portfolio_json(old_json: dict[str, Any]) -> dict[str, Any]:
3841

3942
def convert_portfolios_json(old_json: dict[str, Any]) -> dict[str, Any]:
4043
"""Converts the sonar-config portfolios old JSON report format to the new one"""
41-
new_json = old_json.copy()
42-
for k, v in new_json.items():
43-
new_json[k] = convert_portfolio_json(v)
44-
return util.dict_to_list(new_json, "key")
44+
for k, v in old_json.items():
45+
old_json[k] = convert_portfolio_json(v)
46+
return util.dict_to_list(old_json, "key")

0 commit comments

Comments
 (0)