Community
Participate
Working Groups
I'd like to do some checks in a plugin (to check that the user is not committing things it shouldn't). Is there a way to have an extension point called (with details on what's about to be committed) so that I can give a message and stop such a commit from happening? (i.e.: which'd be a sort of pre-commit hook which plugins can act on)
I'm second to request this: We want enforce validity check for Jira ticket numbers if commit message contains something like "RESOLVED: JIRA-123". What we need is something similar to the "wizard page" validating style where 3rd party can contribute validation check(s) for the upcoming operation. The most obvious place to integrate such pre commit check would be in org.eclipse.egit.ui.internal.commit.CommitUI.performCommit(Repository, CommitOperation, boolean) code. To do this, CommitOperation could extend BaseOperation and CommitUI would add pre/post commit tasks read from extension registry. Unfortunately IEGitOperation.PreExecuteTask does not have access to the actual operation which makes this API unusable for our needs. However, IEGitOperation can define PreExecuteValidator interface with the following signature: /** * Validator which will be asked for confirmation before execution begins */ interface PreExecuteValidator<T extends IEGitOperation> { /** * Validates given task before execution * * @param operation * the task to validate upfront * * @param repository * the git repository * * @param monitor * a progress monitor, or <code>null</code> if progress * reporting and cancellation are not desired * @return * status object with the result of the validation. The * operation will be executed only of the status is OK. */ IStatus preExecute(T operation, Repository repository, IProgressMonitor monitor); } The extension would expect clients contributing PreExecuteValidator for commit (or possibly other operation). Additionally to the use in the CommitUI.performCommit() code,it would be nice to have something validating commit messages "on typing" in the staging view/commit dialog, but this is for another bug.