added support for native git post-receive hook

This commit is contained in:
Sebastian Sdorra
2011-08-03 09:28:26 +02:00
parent 3c12ddedf7
commit 26fd9f6e6c
5 changed files with 398 additions and 148 deletions

View File

@@ -89,6 +89,14 @@ public class IOUtil
"/opt/csw/bin"
};
/** Field description */
private static final String[] EXTENSION_SCRIPT_UNIX = { ".sh", ".csh",
".bsh" };
/** Field description */
private static final String[] EXTENSION_SCRIPT_WINDOWS = { ".bat", ".cmd",
".exe" };
/** Field description */
private static final Logger logger =
LoggerFactory.getLogger(IOUtil.class.getName());
@@ -582,6 +590,38 @@ public class IOUtil
return cmds;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param basePath
*
* @since 1.6
* @return
*/
public static File getScript(String basePath)
{
return getScript(new File(basePath), basePath);
}
/**
* Method description
*
*
* @param baseFile
*
* @since 1.6
* @return
*/
public static File getScript(File baseFile)
{
return getScript(baseFile, baseFile.getAbsolutePath());
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -637,6 +677,53 @@ public class IOUtil
return extensions;
}
/**
* Method description
*
*
* @param baseFile
* @param basePath
*
* @since 1.6
* @return
*/
private static File getScript(File baseFile, String basePath)
{
File script = null;
if (baseFile.exists())
{
script = baseFile;
}
else
{
String[] extensions = null;
if (SystemUtil.isWindows())
{
extensions = EXTENSION_SCRIPT_WINDOWS;
}
else
{
extensions = EXTENSION_SCRIPT_UNIX;
}
for (String ext : extensions)
{
File file = new File(basePath.concat(ext));
if (file.exists())
{
script = file;
break;
}
}
}
return script;
}
/**
* Method description
*

View File

@@ -334,10 +334,10 @@ public class Util
*
* @return
*/
public static String nonNull(String value)
public static String nonNull(Object value)
{
return (value != null)
? value
? value.toString()
: "";
}