Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » PostCommitHook
PostCommitHook [message #1842636] Fri, 25 June 2021 23:50 Go to next message
Suraj Arja is currently offline Suraj ArjaFriend
Messages: 2
Registered: June 2021
Junior Member
I started using JGit library for handling the git repositories from my application. I want to perform certain action within my application when a commit is made on a certain repository.
I see there is PostCommitHook with JGit. I am not able to use it for listening the post-commit event. Is there some example to follow?
Re: PostCommitHook [message #1842717 is a reply to message #1842636] Tue, 29 June 2021 14:04 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1184
Registered: July 2009
Senior Member
I guess PostCommitHook is not what you are looking for.
It's not calling some listener but executing a hook script if present in the repository.

See HookTest.testAllCommitHooks().

Re: PostCommitHook [message #1843000 is a reply to message #1842717] Fri, 09 July 2021 19:20 Go to previous message
Suraj Arja is currently offline Suraj ArjaFriend
Messages: 2
Registered: June 2021
Junior Member
Hello Matthias, thanks for a reply and sorry I could come back here earlier. I think that RepositoryListener is something going to help.

In summary, my application wants to monitor a particular file in master branch of a repo. Whenever there is some commit made on that file, my application wants to do certain task.
I see there are multiple subinterfaces of RepositoryListener: BeforeDfsPackIndexLoadedListener, ConfigChangedListener, DfsPacksChangedListener, IndexChangedListener, RefsChangedListener

Firstly, I am not sure which listener I should use in my context.

I tried to configure one of the listener and I am not able to see that working. I am adding an instance of my custom listener class (which implements RefsChangedListener) with the git.
Git git = .....; // get the instance of Git
git.getRepository().getListenerList().addRefsChangedListener(listener);


I don't see onRefsChanged() called even after doing many transactions with the repo. Any comment what I am doing wrong.
Previous Topic:Is there a way to use the Object Inserter and have it show up in the File system
Next Topic:What else can cause "[lock failed]" besides branches that are dups except for case?
Goto Forum:
  


Current Time: Mon Sep 27 11:21:28 GMT 2021

Powered by FUDForum. Page generated in 0.01560 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top