Commit 737d3d8a authored by Laurent Peuch's avatar Laurent Peuch
Browse files

feat(add-new-rules): add set-cubicweb-max-version new rule when missing

parent 1f030904dd28
import os
import yaml
from ruamel.yaml import YAML
from cube_doctor import Command
......@@ -13,7 +14,10 @@ class AddNewRules(Command):
return "continue"
def modify_code(self, cube, repo, root_files, branches, other_args):
cube_doctor_yaml = yaml.safe_load(open(repo.path / ".cube-doctor.yml"))
yaml = YAML(typ="safe")
yaml.default_flow_style = False
cube_doctor_yaml = yaml.load(open(repo.path / ".cube-doctor.yml"))
if "add-deb-publish" in cube_doctor_yaml["rules"]:
os.system(f"sed -i '/add-deb-publish:/d' {repo.path / '.cube-doctor.yml'}")
......@@ -22,3 +26,15 @@ class AddNewRules(Command):
"branch_name": "topic/default/remove-add-deb-publish-rule",
"commit_message": "chore(cube-doctor): add-deb-publish rule has been removed",
if "set-cubicweb-max-version" not in cube_doctor_yaml["rules"]:
modified_cube_doctor_yaml = cube_doctor_yaml.copy()
modified_cube_doctor_yaml["rules"]["set-cubicweb-max-version"] = None
with open(repo.path / ".cube-doctor.yml", "w") as f:
yaml.dump(modified_cube_doctor_yaml, f)
yield {
"branch_name": "topic/default/add-set-cubicweb-max-version",
"commit_message": "feat(cube-doctor): add add-set-cubicweb-max-version",
......@@ -9,3 +9,4 @@ hg+
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment