clang-power-tools
clang-power-tools copied to clipboard
Using clang-tidy fix with Perforce doesn't work unless files are already checked out
I'm using CPT in VS2015 with the Perforce/Helix plugin P4VS for version control. In Perforce files which are not checked out in a local workspace are read only (compare to git where files can be freely edited and git detects changes). When CPT runs it can't apply fixes automatically because the files are read only, resulting in lots of "clang-tidy failed to apply suggested fixes" errors in the Clang Power Tools output. If I want these fixes to be applied I need to checkout all .cpp and .h files that clang-tidy might hit.
In my day to day work the P4VS plugin checks out files when I start editing them. Is it possible for CPT to do something similar when clang-tidy is run to fix issues? Is this something that seems relatively easy to add? I'm interested in making this happen because Perforce is widely used in my workplace.
For codebase wide fixes I currently need to run p4 edit .../*.cpp .../*.h
then revert unchanged files after clang-tidy has run. I'm okay doing this but I'd like to make the experience of using CPT as accessible and easy as possible for coworkers.
In some cases I can see this behavior being desirable though. If I run clang-tidy fix on a single source file it applies fixes to included headers as well but I might not want that under certain circumstances.
Hello,
Unfortunately we cannot currently implement this (specific to Perforce) because our infrastructure is oriented around Git, not Perforce.
If I understand your requirements right, a Pre-build
& Post-build
CMD events feature would help.
That would leave the user (you) in charge of triggering specific Perforce actions. We could look into that.
I want to make sure I understand you correctly, you mean Pre-build
& Post-build
for running Clang Tidy?
Hi @matthew-dews,
Check out this blog about Tidy-Fix, we added a new functionality that will keep your history changes (after fixes), I think this will help you with local files
You need just to update Clang Power Tools to latest version 2023.6.0
Kind regards, Marina