Package: pre-commit-hooks-g
= Pre-Commit Hooks for GThis is the repository for holding the pre-commit hooks for G code (LabVIEW).The code was developed over the pre-commit platform in python and uses G-CLI to call labview.== UsageSetup and usage of pre-commit hooks are well documented in link:https://pre-commit.com/#usage[Pre-Commit website].Each hook has its own configuration and that is detailed down below in the available hooks section.The main tool has some options that can be used as arguments in each of the hooks. Use this with caution, as this is not a global configuration, and can cause undesired effects running on multiple hooks at once.[cols="1,1"]|===|Argument |description|--allow-dialogs|Allow dialogs option from G-CLI. Check G-CLI documentation.|--debug|Enables debugging of the hook wrapper, it does not close the VI after running.|--hook-args and \--|It is possible to forward args to the hooks. Use this as your last argument and the arguments to the hook as items in the list. Include a \-- at the end to split from the wrapper arguments. Arguments need to use a different leading notation, not - or \--, as they are recognized as python argparse arguments.|===== Available HooksThe available hooks are mainly listed in the .pre-commit-hooks.yaml.Here is a small description on the ones available now. For supported file types you may check the .pre-commit-hooks.yaml file.* VI Broke - check if VI is in executable state.* VI Description - check if there is a VI description.* Yellow - G Code formatter - format the VIs, rearranging Windows, ... (Some steps were borrowed from the Nattify). None of the steps are configurable, not even by INI entries. Name is a reference to the Black, which is a opinionated formatter for Python.== DesignBecause there is no support for direct G support in the pre-commits, it was decided to create a python wrapper that will call the labview hooks using G-CLI.The hooks were simplified with a LabVIEW Wrapper, so they do not need to handle all arguments received by the Pre-Commit framework.Instead it just receive a cluster with the required data.The Python code handles arguments and calling the G-CLI for the specific hookThe coded iterates over the different files in one call, avoiding performance issues by calling the hook wrapper many times.== ContributingYou can decide to create new hooks or contribute with the python code.Either way, make sure to install pre-commit.=== Python CodeUses at least Python 3.11, as it was not tested with other versions (to do).Requirementes:* Python 3.11* PoetryTo run it use:* `make setup` - Setup* `make tests` - Test* `make format` - Code formatting* `make all` - Format and test=== Developing new hooksNew hooks can be developed following the template in docs/hook-template.vit.Make sure you close the VI reference if you open it.Create tests accordingly for each of the supported files types and eventually VI types.Fork, modify the code and submit a merge request back.=== External hooksExternal hooks are not supported yet, although it is under investigation.This means if you want to develop your own hook you need to submit a MR or create a hook in your own fork.== Dependencies- G-CLI- Caraya Unit Test Framework- Python 3.11 and Poetry== AuthorFelipe Pinheiro Silva - felipefoz@gmail.com