diff options
author | James Moger <james.moger@gitblit.com> | 2015-05-22 12:13:39 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2015-05-22 12:13:39 -0400 |
commit | 8a28d0f3df3d4800f82250eec597150ee5dfc933 (patch) | |
tree | e5a21b0e26671186dd75b927e1aa5c3cbd32d702 /src/main/java/com/gitblit/manager | |
parent | 63fdd0d3a0eb1aad92b180c6238bfa89915da999 (diff) | |
download | gitblit-8a28d0f3df3d4800f82250eec597150ee5dfc933.tar.gz gitblit-8a28d0f3df3d4800f82250eec597150ee5dfc933.zip |
Add onFork and onRename methods to RepositoryLifeCycleListener
Diffstat (limited to 'src/main/java/com/gitblit/manager')
-rw-r--r-- | src/main/java/com/gitblit/manager/GitblitManager.java | 11 | ||||
-rw-r--r-- | src/main/java/com/gitblit/manager/RepositoryManager.java | 12 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/main/java/com/gitblit/manager/GitblitManager.java b/src/main/java/com/gitblit/manager/GitblitManager.java index 9692e654..deaa5347 100644 --- a/src/main/java/com/gitblit/manager/GitblitManager.java +++ b/src/main/java/com/gitblit/manager/GitblitManager.java @@ -54,6 +54,7 @@ import com.gitblit.Constants.FederationToken; import com.gitblit.Constants.Role; import com.gitblit.GitBlitException; import com.gitblit.IStoredSettings; +import com.gitblit.extensions.RepositoryLifeCycleListener; import com.gitblit.models.FederationModel; import com.gitblit.models.FederationProposal; import com.gitblit.models.FederationSet; @@ -276,6 +277,16 @@ public class GitblitManager implements IGitblit { // add this clone to the cached model repositoryManager.addToCachedRepositoryList(cloneModel); + + if (pluginManager != null) { + for (RepositoryLifeCycleListener listener : pluginManager.getExtensions(RepositoryLifeCycleListener.class)) { + try { + listener.onFork(repository, cloneModel); + } catch (Throwable t) { + logger.error(String.format("failed to call plugin onFork %s", repository.name), t); + } + } + } return cloneModel; } diff --git a/src/main/java/com/gitblit/manager/RepositoryManager.java b/src/main/java/com/gitblit/manager/RepositoryManager.java index c2c6088e..23fd0224 100644 --- a/src/main/java/com/gitblit/manager/RepositoryManager.java +++ b/src/main/java/com/gitblit/manager/RepositoryManager.java @@ -1375,6 +1375,7 @@ public class RepositoryManager implements IRepositoryManager { repository.name = repository.name.substring(projectPath.length() + 1); } } + boolean isRename = false; if (isCreate) { // ensure created repository name ends with .git if (!repository.name.toLowerCase().endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) { @@ -1391,7 +1392,8 @@ public class RepositoryManager implements IRepositoryManager { r = JGitUtils.createRepository(repositoriesFolder, repository.name, shared); } else { // rename repository - if (!repositoryName.equalsIgnoreCase(repository.name)) { + isRename = !repositoryName.equalsIgnoreCase(repository.name); + if (isRename) { if (!repository.name.toLowerCase().endsWith( org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) { repository.name += org.eclipse.jgit.lib.Constants.DOT_GIT_EXT; @@ -1511,6 +1513,14 @@ public class RepositoryManager implements IRepositoryManager { logger.error(String.format("failed to call plugin onCreation %s", repositoryName), t); } } + } else if (isRename && pluginManager != null) { + for (RepositoryLifeCycleListener listener : pluginManager.getExtensions(RepositoryLifeCycleListener.class)) { + try { + listener.onRename(repositoryName, repository); + } catch (Throwable t) { + logger.error(String.format("failed to call plugin onRename %s", repositoryName), t); + } + } } } |