OCA / odoo-pre-commit-hooks

Linters of Odoo addons that complement pylint-odoo
GNU Affero General Public License v3.0
10 stars 12 forks source link

Run on modified files only #11

Closed sbidoul closed 2 years ago

sbidoul commented 2 years ago

By default, pre-commit passes modified files to the hooks.

This project's hook has

types: [python]
files: /\_\_(manifest|openerp)\_\_\.py$

So it will trigger only on addon manifests? Or it should be configured with always_run: true?

Could it be possible to run the hook on modified files only? For instance, there is no need to check all .po files if they have not been modified.

That could be important for performance, especially when running locally.

moylop260 commented 2 years ago

Good question!

Thank you!

I think always_run: true is good for the data/demo manifest section.

A few checks need to be evaluated with the whole Odoo module

The first version was using the XML files but it needs a way to get all the XML-IDs of all the files not only the changed one

Even, I have improved the performance by re-using the XML nodes compared with pylint

So, I have decided to change it to evaluate the whole module because you can add a new data file in the manifest without changing the XML itself and it needs to be evaluated too

Similar case for CSV files

However, you have a good point for .po files since we don't have this case of use for these kinds of files

Let me check how can we create a separate hook only for PO files...

Thank you for the issue

sbidoul commented 2 years ago

I'm wondering if there are existing hooks for .po files. After all our check are not really Odoo-specific.

moylop260 commented 2 years ago

You are right!

I feel the same

It could be great!

moylop260 commented 2 years ago

For record, the option always_run: true is not working as we thought:

This option is related to unmatched files

So, we will need to consider all the odoo module extension files as XML, CSV, and manifest files in order to group them by module and run only one time the checks over the modules...