I am writing a plug-in for Trac. I would like to add an event to the time line each time the plug-in receives some data from a Git post-receive hook.
Looking at the timeline API, it seems you can only add new source of events. So you are responsible for retrieving and displaying the data. I would prefer saving my event to an existent source.
Where should I look in the Trac API to save events?
ps: my plan is to rely on a remote repository and remote web interface to the code like Github.
pss: The time line has to display commits from the main project git repository and its clones. I don't want to host a copy of every repository that matter to the project.
The timeline API is a level higher than what you need to do. There is a general VCS implementation of it in ChangesetModule, which delegates the changeset (event) retrieval itself to a VCS-specific Repository
. So you should implement the versioncontrol API instead.
The API is designed for a “pull model”, in which Trac queries the VCS when constructing a timeline. If you really prefer a “push model” (why?), you could try working off the CacheRepository implementation as a base, injecting your events into the cache, or just writing an event-storing repository from scratch. Be aware that this goes against the grain of the existing design, and will very probably be unnecessary extra effort.
I suggest that you go with the normal pull model instead, it will be easier and cleaner. You could use the Subversion implementation or the Mercurial implementation as a reference, and probably use GitPython to talk to git
.