Execute terminal action before opening GIT commit dialog
已回答
Hi, I want to execute a terminal action just before to show the GIT commit dialog.
I successfully created a plugin to launch the terminal action I wanted, but I don't find how to open the GIT commit dialog.
Thanks
请先登录再写评论。
Probably, you can register `com.intellij.openapi.vcs.checkin.CheckinHandlerFactory` and perform your action in `CheckinHandlerFactory#createHandler`, `CheckinHandlerFactory#createSystemReadyHandler` or `CheckinHandler#getBeforeCheckinConfigurationPanel`.
They will be called whenever commit dialog is opened. Though, they are called in EDT, so long external commands are not advised (or, at least, should be shown under progress).
To open commit dialog you can use `com.intellij.openapi.vcs.AbstractVcsHelper#commitChanges`.
What should this terminal action do?
Thanks for the response I will try it,
In fact I use Rider for unity development and each time I create file outside of rider I have to select the files to add to git manually, I tried with a file watcher but it's called too often. So my command just make a simple :
After that I would like to clean up a little for deleted folder so add something like :
find Assets -type d -depth -empty -exec echo "Removing "{} \; -exec rmdir {} \; -exec rm {}.meta \;before
I tried with CheckinHandlerFactory and it work great.
Thank you very much !
Ok now I have a problem, when the commit dialog show up, the files added by bit add . are not in the list.
Is there a way to force a git refresh ?
If you update file statuses via external process, you need to:
1. notify IDE about these changes `com.intellij.openapi.vcs.changes.VcsDirtyScopeManager#markEverythingDirty` or `VcsDirtyScopeManager#filePathsDirty(List<FilePath> affectedPaths, ...)`
2. and force it to refresh changes via `com.intellij.openapi.vcs.changes.ChangeListManagerImpl#scheduleUpdate()`
OK thanks, It works now.
I had to make a menu action instead of the BeforeCheckinDialogHandler because the added files are not checked when I use the BeforeCheckinDialogHandler.