From 819efdc8c5ea633e9be1e744ade8b197d21a1962 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 11 Apr 2014 17:55:53 -0400 Subject: Allow ReceiveHook extensions --- src/site/setup_plugins.mkd | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/site') diff --git a/src/site/setup_plugins.mkd b/src/site/setup_plugins.mkd index b609a683..b956cc15 100644 --- a/src/site/setup_plugins.mkd +++ b/src/site/setup_plugins.mkd @@ -54,13 +54,47 @@ Gitblit also supports loading multiple plugin registries. Just place another ** ### Extension Point: SSH DispatchCommand -You can provide your own custom SSH commands by extending the DispatchCommand. +You can provide your own custom SSH commands by extending the *DispatchCommand* class. For some examples of how to do this, please see: [gitblit-cookbook-plugin (Maven project)](https://dev.gitblit.com/summary/gitblit-cookbook-plugin.git) [gitblit-powertools-plugin (Ant/Moxie project)](https://dev.gitblit.com/summary/gitblit-powertools-plugin.git) +### Extension Point: Pre- and Post- Receive Hook + +You can provide your own custom pre and/or post receive hooks by extending the *ReceiveHook* class. + +```java +import com.gitblit.extensions.ReceiveHook; +import ro.fortsoft.pf4j.Extension; + +@Extension +public class MyHook extends ReceiveHook { + + @Override + public void onPreReceive(GitblitReceivePack receivePack, Collection commands) { + RepositoryModel repository = receivePack.getRepositoryModel(); + UserModel user = receivePack.getUserModel(); + receivePack.sendInfo("Hi {0}, I see {1} commands for {2} onPreReceive", + user.getDisplayName(), + commands.size(), + repository.name); + } + + @Override + public void onPostReceive(GitblitReceivePack receivePack, Collection commands) { + RepositoryModel repository = receivePack.getRepositoryModel(); + UserModel user = receivePack.getUserModel(); + receivePack.sendInfo("Hi {0}, I see {1} commands for {2} onPostReceive", + user.getDisplayName(), + commands.size(), + repository.name); + } +} + +``` + ### Mac OSX Fonts Gitblit's core SSH commands and those in the *powertools* plugin rely on use of ANSI border characters to provide a pretty presentation of data. Unfortunately, the fonts provided by Apple - while very nice - don't work well with ANSI border characters. The following public domain fixed-width, fixed-point, bitmapped fonts work very nicely. I find the 6x12 font with a line spacing of ~0.8 to be quite acceptable. -- cgit v1.2.3