From c44dd099a432094a12131cf60dfc8a19f5aa8101 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 13 Nov 2013 17:56:50 -0500 Subject: Implement mirror executor (issue-5) The mirror executor will fetch ref updates for repository mirrors. This feature is disabled by default and can be enabled by setting git.enableMirroring=true. The period between update checks is configurable, but it is global. An individual rpeository may not set it's own update schedule. Requirements: 1. you must manually clone the repository using native git git clone --mirror git://somewhere.com/myrepo.git 2. the "origin" remote must be the mirror source 3. the "origin" repository must be accessible without authentication OR the credentials must be embedded in the origin url (not recommended) Notes: 1. "origin" SSH urls are untested and not likely to work 2. mirrors cloned while Gitblit is running are likely to require clearing the gitblit cache (link on the repositories page of an administrator account) 3. Gitblit will automatically repair any invalid fetch refspecs with a "//" sequence. Change-Id: I4bbe3fb2df106366ae4c2313596d0fab0dfcac46 --- src/main/java/com/gitblit/git/GitblitReceivePack.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/main/java/com/gitblit/git') diff --git a/src/main/java/com/gitblit/git/GitblitReceivePack.java b/src/main/java/com/gitblit/git/GitblitReceivePack.java index e6ff5721..ba200b25 100644 --- a/src/main/java/com/gitblit/git/GitblitReceivePack.java +++ b/src/main/java/com/gitblit/git/GitblitReceivePack.java @@ -120,6 +120,14 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P @Override public void onPreReceive(ReceivePack rp, Collection commands) { + if (repository.isMirror) { + // repository is a mirror + for (ReceiveCommand cmd : commands) { + sendRejection(cmd, "Gitblit does not allow pushes to \"{0}\" because it is a mirror!", repository.name); + } + return; + } + if (repository.isFrozen) { // repository is frozen/readonly for (ReceiveCommand cmd : commands) { -- cgit v1.2.3