Is it possible to setup IDEA to prevent index of being commited if code matches some criteria, for example contain some special comment like //failcommit
?
IDEA warns you on commit if there is //todo
or //fixme
comments in modified files. I'd like to config something similar but instead of warning it should block commit action at all.
How about having git do the commit check and failure, instead of intellij? Then it doesn't matter what IDE you are using. If that is acceptable then you could set up a git pre-commit hook that fails if the target comment is found.
Git hooks documentation: https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks
Example pre-commit hook that fails if 'FIXME' is found anywhere: https://gist.github.com/kuy/5d1151fd5897a9b84c06
There are no settings in IDEA to configure this. You could develop your own CheckinHandler to do this, and add it to the Before commit section.
The question is why do you need this? Why the warning that allows you to cancel commit is not an option? You could just configure a custom pattern for TODO.
Using git hooks is another option.
BTW, IDEA does not commit index. It commits individual files, using git commit --only
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.