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 product version check pre-commit #24

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

rruiter87
Copy link
Contributor

A pre-commit to check if the product version is saved in the xml file

<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">

It only fails when it detects the Product version. I thought about automatically removing it as well, but this can be easily done with a single click for all files in the project. And I was not sure what it would do if some files have a product version and others not.

@rruiter87
Copy link
Contributor Author

gentle ping

@ZLLentz
Copy link
Member

ZLLentz commented Mar 27, 2024

Sorry, I've been super busy, I'll circle back here soon

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Concept, code, and the documentation update all look great to me
  • Ran as myself and saw:
    • Repos with no product version properly passing
    • Repos with product version properly failing

I thought it was all great but I noticed something weird- in some cases only some of the offending files are flagged.

$ pre-commit try-repo ../pre-commit-hooks no-product-version --verbose --all-files
===============================================================================
Using config:
===============================================================================
repos:
-   repo: ../pre-commit-hooks
    rev: 7d55f6c38cd0a1ef663151a673a3dfa2f9fc2291
    hooks:
    -   id: no-product-version
===============================================================================
[INFO] Initializing environment for ../pre-commit-hooks.
[INFO] Installing environment for ../pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check for product version................................................Failed
- hook id: no-product-version
- duration: 0.12s
- exit code: 1

Detected product version (3.1.4022.18) in plc-kfe-motion/kfe_motion/GVLs/RTDSK0.TcGVL. To disable this go to Project settings > Advanced and disable 'Write product version in files.'
Detected product version (3.1.4022.18) in plc-kfe-motion/kfe_motion/POUs/PRG_RTDSK0.TcPOU. To disable this go to Project settings > Advanced and disable 'Write product version in files.'
Detected product version (3.1.4022.18) in plc-kfe-motion/kfe_motion/POUs/PRG_IM1K0_XTES.TcPOU. To disable this go to Project settings > Advanced and disable 'Write product version in files.'
Detected product version (3.1.4022.18) in plc-kfe-motion/kfe_motion/POUs/PRG_SL1K0_POWER.TcPOU. To disable this go to Project settings > Advanced and disable 'Write product version in files.'
Detected product version (3.1.4022.18) in plc-kfe-motion/kfe_motion/Temp/FB_SLITS.TcPOU. To disable this go to Project settings > Advanced and disable 'Write product version in files.'
Detected product version (3.1.4022.18) in plc-kfe-motion/kfe_motion/POUs/PRG_ST1K4_TEST.TcPOU. To disable this go to Project settings > Advanced and disable 'Write product version in files.'
$ grep -R ProductVersion .
./plc-kfe-motion/kfe_motion/PlcTask.TcTTO:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/DUTs/E_PositionState.TcDUT:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/DUTs/ST_MPA.TcDUT:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/Temp/FB_MPA.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/Temp/FB_SLITS.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/Temp/FB_SLITS_POWER.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_RTDSK0.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_ST1K4_TEST.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_PF1K0_WFS.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_SL1K0_POWER.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/IM2K0/FB_XPIM_IM2K0.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_1_PlcTask.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_SL2K0_POWER.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_IM1K4_XTES.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_IM2K0_XTES.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_IM1K0_XTES.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_IM1K3_PPM.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_4_LOG.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_3_PMPS_POST.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_AT1K4_SOLID.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/POUs/PRG_2_PMPS_PRE.TcPOU:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/GVLs/Main.TcGVL:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/GVLs/GVL.TcGVL:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">
./plc-kfe-motion/kfe_motion/GVLs/RTDSK0.TcGVL:<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4022.18">

When I run the function directly on a file I always get the correct response, but for some reason some of my files get "missed" when running through the pre-commit mechanics. Maybe some strange pre-commit bug? I think it must be unrelated to your code here.

I'm going to merge and tag the repo at v1.4.0

@ZLLentz ZLLentz merged commit 771de97 into pcdshub:master Mar 27, 2024
@ZLLentz
Copy link
Member

ZLLentz commented Mar 27, 2024

Thank you for your contribution and sorry for the delay!

@rruiter87 rruiter87 deleted the product-version branch April 2, 2024 07:20
@rruiter87
Copy link
Contributor Author

Strange that it changes some but not all files. I guess you can't share the files to reproduce this issue?

I did a quick google search, but I can't find any related issues. My initial thought was that maybe pre-commit has some limit of the number of files that it makes checks. Or maybe it does check them, but in the output the file list is truncated.

@ZLLentz
Copy link
Member

ZLLentz commented Apr 2, 2024

The files are public if you are interested, but I also assume it's something like truncation and am not worrying much. Your code does the right thing for all of these files when applied directly.

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

Successfully merging this pull request may close these issues.

2 participants