mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
fix svn hooks for repositories located on soft links
This commit is contained in:
@@ -46,12 +46,14 @@ import org.tmatesoft.svn.core.internal.io.fs.FSHook;
|
|||||||
import org.tmatesoft.svn.core.internal.io.fs.FSHookEvent;
|
import org.tmatesoft.svn.core.internal.io.fs.FSHookEvent;
|
||||||
import org.tmatesoft.svn.core.internal.io.fs.FSHooks;
|
import org.tmatesoft.svn.core.internal.io.fs.FSHooks;
|
||||||
|
|
||||||
|
import sonia.scm.util.AssertUtil;
|
||||||
import sonia.scm.util.IOUtil;
|
import sonia.scm.util.IOUtil;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -155,10 +157,7 @@ public class SvnRepositoryHook implements FSHook
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String name =
|
String name = getRepositoryName(directory);
|
||||||
directory.getAbsolutePath()
|
|
||||||
.substring(handler.getConfig().getRepositoryDirectory()
|
|
||||||
.getAbsolutePath().length());
|
|
||||||
|
|
||||||
name = IOUtil.trimSeperatorChars(name);
|
name = IOUtil.trimSeperatorChars(name);
|
||||||
repositoryManager.fireHookEvent(SvnRepositoryHandler.TYPE_NAME, name,
|
repositoryManager.fireHookEvent(SvnRepositoryHandler.TYPE_NAME, name,
|
||||||
@@ -176,6 +175,39 @@ public class SvnRepositoryHook implements FSHook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param directory
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private String getRepositoryName(File directory) throws IOException
|
||||||
|
{
|
||||||
|
AssertUtil.assertIsNotNull(directory);
|
||||||
|
|
||||||
|
String name = null;
|
||||||
|
String path = directory.getCanonicalPath();
|
||||||
|
int directoryLength =
|
||||||
|
handler.getConfig().getRepositoryDirectory().getCanonicalPath().length();
|
||||||
|
|
||||||
|
if (directoryLength < path.length())
|
||||||
|
{
|
||||||
|
name = IOUtil.trimSeperatorChars(path.substring(directoryLength));
|
||||||
|
}
|
||||||
|
else if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn("path is shorter as the main hg repository path");
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
Reference in New Issue
Block a user