You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Hook.java 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (C) 2014 Obeo.
  3. * and other copyright owners as documented in the project's IP log.
  4. *
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Distribution License v1.0 which
  7. * accompanies this distribution, is reproduced below, and is
  8. * available at http://www.eclipse.org/org/documents/edl-v10.php
  9. *
  10. * All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or
  13. * without modification, are permitted provided that the following
  14. * conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials provided
  22. * with the distribution.
  23. *
  24. * - Neither the name of the Eclipse Foundation, Inc. nor the
  25. * names of its contributors may be used to endorse or promote
  26. * products derived from this software without specific prior
  27. * written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  30. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  31. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  34. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  35. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  36. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  37. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  38. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  41. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42. */
  43. package org.eclipse.jgit.util;
  44. /**
  45. * An enum describing the different hooks a user can implement to customize his
  46. * repositories.
  47. *
  48. * @since 3.7
  49. */
  50. public enum Hook {
  51. /**
  52. * Literal for the "pre-commit" git hook.
  53. * <p>
  54. * This hook is invoked by git commit, and can be bypassed with the
  55. * "no-verify" option. It takes no parameter, and is invoked before
  56. * obtaining the proposed commit log message and making a commit.
  57. * </p>
  58. * <p>
  59. * A non-zero exit code from the called hook means that the commit should be
  60. * aborted.
  61. * </p>
  62. */
  63. PRE_COMMIT("pre-commit"), //$NON-NLS-1$
  64. /**
  65. * Literal for the "prepare-commit-msg" git hook.
  66. * <p>
  67. * This hook is invoked by git commit right after preparing the default
  68. * message, and before any editing possibility is displayed to the user.
  69. * </p>
  70. * <p>
  71. * A non-zero exit code from the called hook means that the commit should be
  72. * aborted.
  73. * </p>
  74. */
  75. PREPARE_COMMIT_MSG("prepare-commit-msg"), //$NON-NLS-1$
  76. /**
  77. * Literal for the "commit-msg" git hook.
  78. * <p>
  79. * This hook is invoked by git commit, and can be bypassed with the
  80. * "no-verify" option. Its single parameter is the path to the file
  81. * containing the prepared commit message (typically
  82. * "&lt;gitdir>/COMMIT-EDITMSG").
  83. * </p>
  84. * <p>
  85. * A non-zero exit code from the called hook means that the commit should be
  86. * aborted.
  87. * </p>
  88. */
  89. COMMIT_MSG("commit-msg"), //$NON-NLS-1$
  90. /**
  91. * Literal for the "post-commit" git hook.
  92. * <p>
  93. * This hook is invoked by git commit. It takes no parameter and is invoked
  94. * after a commit has been made.
  95. * </p>
  96. * <p>
  97. * The exit code of this hook has no significance.
  98. * </p>
  99. */
  100. POST_COMMIT("post-commit"), //$NON-NLS-1$
  101. /**
  102. * Literal for the "post-rewrite" git hook.
  103. * <p>
  104. * This hook is invoked after commands that rewrite commits (currently, only
  105. * "git rebase" and "git commit --amend"). It a single argument denoting the
  106. * source of the call (one of <code>rebase</code> or <code>amend</code>). It
  107. * then accepts a list of rewritten commits through stdin, in the form
  108. * <code>&lt;old SHA-1> &lt;new SHA-1>LF</code>.
  109. * </p>
  110. * <p>
  111. * The exit code of this hook has no significance.
  112. * </p>
  113. */
  114. POST_REWRITE("post-rewrite"), //$NON-NLS-1$
  115. /**
  116. * Literal for the "pre-rebase" git hook.
  117. * <p>
  118. * </p>
  119. * This hook is invoked right before the rebase operation runs. It accepts
  120. * up to two parameters, the first being the upstream from which the branch
  121. * to rebase has been forked. If the tip of the series of commits to rebase
  122. * is HEAD, the other parameter is unset. Otherwise, that tip is passed as
  123. * the second parameter of the script.
  124. * <p>
  125. * A non-zero exit code from the called hook means that the rebase should be
  126. * aborted.
  127. * </p>
  128. */
  129. PRE_REBASE("pre-rebase"); //$NON-NLS-1$
  130. private final String name;
  131. private Hook(String name) {
  132. this.name = name;
  133. }
  134. /**
  135. * @return The name of this hook.
  136. */
  137. public String getName() {
  138. return name;
  139. }
  140. }