如何将事件添加到Trac事件时间线

时间:2022-06-19 23:56:34

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.

我正在为Trac编写一个插件。每次插件从Git post-receive挂钩接收一些数据时,我想在时间线上添加一个事件。

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.

查看时间轴API,您似乎只能添加新的事件源。因此,您负责检索和显示数据。我宁愿将我的活动保存到现有的来源。

Where should I look in the Trac API to save events?

我应该在哪里查看Trac API来保存事件?

ps: my plan is to rely on a remote repository and remote web interface to the code like Github.

ps:我的计划是依赖远程存储库和远程Web界面来代码,如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.

pss:时间线必须显示主项目git存储库及其克隆的提交。我不想托管与项目有关的每个存储库的副本。

1 个解决方案

#1


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.

时间轴API的级别高于您需要的级别。在ChangesetModule中有一个通用的VCS实现,它将变更集(事件)检索本身委托给特定于VCS的存储库。因此,您应该实现versioncontrol API。

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.

API是为“拉模型”设计的,其中Trac在构造时间轴时查询VCS。如果您真的更喜欢“推模型”(为什么?),您可以尝试将CacheRepository实现作为基础,将事件注入缓存,或者只是从头开始编写事件存储库。请注意,这违背了现有设计的要求,很可能是不必要的额外努力。

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.

我建议你改用普通的拉模型,它会更简单,更清洁。您可以使用Subversion实现或Mercurial实现作为参考,并可能使用GitPython与git对话。

#1


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.

时间轴API的级别高于您需要的级别。在ChangesetModule中有一个通用的VCS实现,它将变更集(事件)检索本身委托给特定于VCS的存储库。因此,您应该实现versioncontrol API。

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.

API是为“拉模型”设计的,其中Trac在构造时间轴时查询VCS。如果您真的更喜欢“推模型”(为什么?),您可以尝试将CacheRepository实现作为基础,将事件注入缓存,或者只是从头开始编写事件存储库。请注意,这违背了现有设计的要求,很可能是不必要的额外努力。

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.

我建议你改用普通的拉模型,它会更简单,更清洁。您可以使用Subversion实现或Mercurial实现作为参考,并可能使用GitPython与git对话。