]> source.dussan.org Git - gitblit.git/commitdiff
Removed unused and untested native hook code
authorJames Moger <james.moger@gitblit.com>
Sat, 5 Jan 2013 20:24:50 +0000 (15:24 -0500)
committerJames Moger <james.moger@gitblit.com>
Sat, 5 Jan 2013 20:24:50 +0000 (15:24 -0500)
src/com/gitblit/GitServlet.java

index 05f38b9d798f97ccd8387876b8324e10cf59c9df..b55df04e9b9263fa998dbb8dfba3fa88d3c7455d 100644 (file)
@@ -18,12 +18,8 @@ package com.gitblit;
 import groovy.lang.Binding;\r
 import groovy.util.GroovyScriptEngine;\r
 \r
-import java.io.BufferedReader;\r
-import java.io.BufferedWriter;\r
 import java.io.File;\r
 import java.io.IOException;\r
-import java.io.InputStreamReader;\r
-import java.io.OutputStreamWriter;\r
 import java.text.MessageFormat;\r
 import java.util.Collection;\r
 import java.util.Enumeration;\r
@@ -284,9 +280,6 @@ public class GitServlet extends org.eclipse.jgit.http.server.GitServlet {
                                                        .getName(), cmd.getResult(), cmd.getMessage()));\r
                                }\r
                        }\r
-\r
-                       // Experimental\r
-                       // runNativeScript(rp, "hooks/pre-receive", commands);\r
                }\r
 \r
                /**\r
@@ -333,9 +326,6 @@ public class GitServlet extends org.eclipse.jgit.http.server.GitServlet {
                        scripts.addAll(GitBlit.self().getPostReceiveScriptsInherited(repository));\r
                        scripts.addAll(repository.postReceiveScripts);\r
                        runGroovy(repository, user, commands, rp, scripts);\r
-                       \r
-                       // Experimental\r
-                       // runNativeScript(rp, "hooks/post-receive", commands);\r
                }\r
 \r
                /**\r
@@ -407,76 +397,5 @@ public class GitServlet extends org.eclipse.jgit.http.server.GitServlet {
                                }\r
                        }\r
                }\r
-\r
-               /**\r
-                * Runs the native push hook script.\r
-                * \r
-                * http://book.git-scm.com/5_git_hooks.html\r
-                * http://longair.net/blog/2011/04/09/missing-git-hooks-documentation/\r
-                * \r
-                * @param rp\r
-                * @param script\r
-                * @param commands\r
-                */\r
-               @SuppressWarnings("unused")\r
-               protected void runNativeScript(ReceivePack rp, String script,\r
-                               Collection<ReceiveCommand> commands) {\r
-\r
-                       Repository repository = rp.getRepository();\r
-                       File scriptFile = new File(repository.getDirectory(), script);\r
-\r
-                       int resultCode = 0;\r
-                       if (scriptFile.exists()) {\r
-                               try {\r
-                                       logger.debug("executing " + scriptFile);\r
-                                       Process process = Runtime.getRuntime().exec(scriptFile.getAbsolutePath(), null,\r
-                                                       repository.getDirectory());\r
-                                       BufferedReader reader = new BufferedReader(new InputStreamReader(\r
-                                                       process.getInputStream()));\r
-                                       BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(\r
-                                                       process.getOutputStream()));\r
-                                       for (ReceiveCommand command : commands) {\r
-                                               switch (command.getType()) {\r
-                                               case UPDATE:\r
-                                                       // updating a ref\r
-                                                       writer.append(MessageFormat.format("{0} {1} {2}\n", command.getOldId()\r
-                                                                       .getName(), command.getNewId().getName(), command.getRefName()));\r
-                                                       break;\r
-                                               case CREATE:\r
-                                                       // new ref\r
-                                                       // oldrev hard-coded to 40? weird.\r
-                                                       writer.append(MessageFormat.format("40 {0} {1}\n", command.getNewId()\r
-                                                                       .getName(), command.getRefName()));\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                                       resultCode = process.waitFor();\r
-\r
-                                       // read and buffer stdin\r
-                                       // this is supposed to be piped back to the git client.\r
-                                       // not sure how to do that right now.\r
-                                       StringBuilder sb = new StringBuilder();\r
-                                       String line = null;\r
-                                       while ((line = reader.readLine()) != null) {\r
-                                               sb.append(line).append('\n');\r
-                                       }\r
-                                       logger.debug(sb.toString());\r
-                               } catch (Throwable e) {\r
-                                       resultCode = -1;\r
-                                       logger.error(\r
-                                                       MessageFormat.format("Failed to execute {0}",\r
-                                                                       scriptFile.getAbsolutePath()), e);\r
-                               }\r
-                       }\r
-\r
-                       // reject push\r
-                       if (resultCode != 0) {\r
-                               for (ReceiveCommand command : commands) {\r
-                                       command.setResult(Result.REJECTED_OTHER_REASON, MessageFormat.format(\r
-                                                       "Native script {0} rejected push or failed",\r
-                                                       scriptFile.getAbsolutePath()));\r
-                               }\r
-                       }\r
-               }\r
        }\r
 }\r