mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-08 16:42:10 +01:00
indent
This commit is contained in:
@@ -35,12 +35,16 @@ package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -52,85 +56,114 @@ public class RepositoryUtil
|
||||
/** the logger for RepositoryUtil */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(RepositoryUtil.class);
|
||||
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param directoryPath
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(AbstractRepositoryHandler handler, String directoryPath) throws IOException
|
||||
public static String getRepositoryName(AbstractRepositoryHandler handler,
|
||||
String directoryPath)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(handler.getConfig().getRepositoryDirectory(), new File(directoryPath));
|
||||
return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
|
||||
new File(directoryPath));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(SimpleRepositoryConfig config, String directoryPath) throws IOException
|
||||
{
|
||||
return getRepositoryName(config.getRepositoryDirectory(), new File(directoryPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param config
|
||||
* @param directoryPath
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(AbstractRepositoryHandler handler, File directory) throws IOException
|
||||
public static String getRepositoryName(SimpleRepositoryConfig config,
|
||||
String directoryPath)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(handler.getConfig().getRepositoryDirectory(), directory);
|
||||
return getRepositoryName(config.getRepositoryDirectory(),
|
||||
new File(directoryPath));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param handler
|
||||
* @param directory
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(SimpleRepositoryConfig config, File directory) throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(AbstractRepositoryHandler handler,
|
||||
File directory)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(handler.getConfig().getRepositoryDirectory(),
|
||||
directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param config
|
||||
* @param directory
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(SimpleRepositoryConfig config,
|
||||
File directory)
|
||||
throws IOException
|
||||
{
|
||||
return getRepositoryName(config.getRepositoryDirectory(), directory);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param baseDirectory
|
||||
* @param directory
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String getRepositoryName(File baseDirectory, File directory) throws IOException
|
||||
public static String getRepositoryName(File baseDirectory, File directory)
|
||||
throws IOException
|
||||
{
|
||||
String name = null;
|
||||
|
||||
String path = directory.getCanonicalPath();
|
||||
int directoryLength = baseDirectory.getCanonicalPath().length();
|
||||
String name = null;
|
||||
String path = directory.getCanonicalPath();
|
||||
int directoryLength = baseDirectory.getCanonicalPath().length();
|
||||
|
||||
if (directoryLength < path.length())
|
||||
{
|
||||
name = IOUtil.trimSeperatorChars(path.substring(directoryLength));
|
||||
// replace windows path seperator
|
||||
name = name.replaceAll("\\\\", "/");
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("path is shorter as the main hg repository path");
|
||||
}
|
||||
|
||||
return name;
|
||||
if (directoryLength < path.length())
|
||||
{
|
||||
name = IOUtil.trimSeperatorChars(path.substring(directoryLength));
|
||||
|
||||
// replace windows path seperator
|
||||
name = name.replaceAll("\\\\", "/");
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("path is shorter as the main hg repository path");
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import sonia.scm.repository.GitRepositoryHookEvent;
|
||||
import sonia.scm.repository.RepositoryHookType;
|
||||
import sonia.scm.repository.RepositoryManager;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.RepositoryUtil;
|
||||
import sonia.scm.util.IOUtil;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
@@ -61,7 +62,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import sonia.scm.repository.RepositoryUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -93,8 +93,10 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
||||
*
|
||||
*
|
||||
* @param repositoryManager
|
||||
* @param handler
|
||||
*/
|
||||
public GitReceiveHook(RepositoryManager repositoryManager, GitRepositoryHandler handler)
|
||||
public GitReceiveHook(RepositoryManager repositoryManager,
|
||||
GitRepositoryHandler handler)
|
||||
{
|
||||
this.repositoryManager = repositoryManager;
|
||||
this.handler = handler;
|
||||
@@ -215,7 +217,8 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
||||
{
|
||||
try
|
||||
{
|
||||
String repositoryName = RepositoryUtil.getRepositoryName(handler, directory);
|
||||
String repositoryName = RepositoryUtil.getRepositoryName(handler,
|
||||
directory);
|
||||
GitRepositoryHookEvent e = new GitRepositoryHookEvent(directory, newId,
|
||||
oldId, type);
|
||||
|
||||
@@ -364,9 +367,9 @@ public class GitReceiveHook implements PreReceiveHook, PostReceiveHook
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private RepositoryManager repositoryManager;
|
||||
|
||||
/** Field description */
|
||||
private GitRepositoryHandler handler;
|
||||
|
||||
/** Field description */
|
||||
private RepositoryManager repositoryManager;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,11 @@ public class GitReceivePackFactory
|
||||
*
|
||||
*
|
||||
* @param repositoryManager
|
||||
* @param handler
|
||||
*/
|
||||
@Inject
|
||||
public GitReceivePackFactory(RepositoryManager repositoryManager, GitRepositoryHandler handler)
|
||||
public GitReceivePackFactory(RepositoryManager repositoryManager,
|
||||
GitRepositoryHandler handler)
|
||||
{
|
||||
hook = new GitReceiveHook(repositoryManager, handler);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user