Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cli argument: --exit-zero #70

Open
zwgshr opened this issue Feb 8, 2023 · 1 comment
Open

add cli argument: --exit-zero #70

zwgshr opened this issue Feb 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@zwgshr
Copy link

zwgshr commented Feb 8, 2023

Describe the solution you'd like

  - repo: http://gitea.dtdream.vip/z1459/odoo-pre-commit-hooks
    rev: v0.0.23.1
    hooks:
      - id: oca-checks-odoo-module
        args:
          - --exit-zero
        verbose: True
Checks for Odoo modules..................................................Passed
- hook id: oca-checks-odoo-module
- duration: 0.08s

****xml-duplicate-record-id****
myaddons/dtdream_sale_project_state/views/dtdream_finance_bom_config.xml:3 Duplicate xml record id "data/dtdream_finance_bom_config_form_noupdate_0" in myaddons/dtdream_sale_project_state/views/dtdream_finance_bom_config.xml:18 - [xml-duplicate-record-id]

Additional context
Add any other context about the feature request here.

diff --git a/src/oca_pre_commit_hooks/global_parser.py b/src/oca_pre_commit_hooks/global_parser.py
index d0247b7..4ec694d 100644
--- a/src/oca_pre_commit_hooks/global_parser.py
+++ b/src/oca_pre_commit_hooks/global_parser.py
@@ -25,6 +25,12 @@ class GlobalParser(argparse.ArgumentParser):
             default=False,
             help="If enabled so disable verbose mode.",
         )
+        self.add_argument(
+            "--exit-zero",
+            action="store_true",
+            default=False,
+            help="If enabled so always exit zero.",
+        )
         self.add_argument(
             "--no-exit",
             action="store_true",



diff --git a/src/oca_pre_commit_hooks/checks_odoo_module.py b/src/oca_pre_commit_hooks/checks_odoo_module.py
index 0f356a8..09a6081 100755
--- a/src/oca_pre_commit_hooks/checks_odoo_module.py
+++ b/src/oca_pre_commit_hooks/checks_odoo_module.py
@@ -169,7 +169,7 @@ def lookup_manifest_paths(filenames_or_modules):
     return odoo_module_files_changed
 
 
-def run(files_or_modules, enable=None, disable=None, no_verbose=False, no_exit=False, list_msgs=False):
+def run(files_or_modules, enable=None, disable=None, no_verbose=False, no_exit=False, list_msgs=False, exit_zero=False):
     if list_msgs:
         _, checks_docstring = utils.get_checks_docstring(
             [ChecksOdooModule, checks_odoo_module_csv.ChecksOdooModuleCSV, checks_odoo_module_xml.ChecksOdooModuleXML]
@@ -208,6 +208,8 @@ def run(files_or_modules, enable=None, disable=None, no_verbose=False, no_exit=F
                 checks_obj.print(f"{msg} - [{check_error}]")
     if no_exit:
         return all_check_errors
+    if exit_zero:
+        return sys.exit(0)
     sys.exit(exit_status)
@zwgshr zwgshr added the enhancement New feature or request label Feb 8, 2023
@zwgshr
Copy link
Author

zwgshr commented Feb 8, 2023

Sorry, I don't have enough time and ability to submit a qualified PR, I hope someone can implement this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant