Search code examples
gitvisual-studio-codevscode-extensions

Listenting to vscode-git commit events


I am trying to build an extension with vscode, and I want some action to be done while the user commits the code in their repo. Is there a way to listen to vscode-git API commit events from my custom extension ? I am using the API from https://github.com/microsoft/vscode/tree/main/extensions/git but I dont see any event that I can use for commits.

Thoughts ?


Solution

  • An onDidCommit event was recently added to the built-in git extension in vscode, see

    https://github.com/microsoft/vscode/commit/5be6890cf5f60bec243715b92f33e97a197e1413

    and

    https://github.com/microsoft/vscode/blob/856d46ed86cacc939504e0d9d77fb8dfc12f9efc/extensions/git/src/api/api1.ts#L69

    readonly onDidCommit: Event<void> = mapEvent<OperationResult, void>(filterEvent(this.repository.onDidRunOperation, e => e.operation === Operation.Commit), () => null);