return;\r
}\r
\r
+ logRefChange(commands);\r
+ updateIncrementalPushTags(commands);\r
+ updateGitblitRefLog(commands);\r
+\r
+ // check for updates pushed to the BranchTicketService branch\r
+ // if the BranchTicketService is active it will reindex, as appropriate\r
+ for (ReceiveCommand cmd : commands) {\r
+ if (Result.OK.equals(cmd.getResult())\r
+ && BranchTicketService.BRANCH.equals(cmd.getRefName())) {\r
+ rp.getRepository().fireEvent(new ReceiveCommandEvent(repository, cmd));\r
+ }\r
+ }\r
+\r
+ // call post-receive plugins\r
+ for (ReceiveHook hook : gitblit.getExtensions(ReceiveHook.class)) {\r
+ try {\r
+ hook.onPostReceive(this, commands);\r
+ } catch (Exception e) {\r
+ LOGGER.error("Failed to execute extension", e);\r
+ }\r
+ }\r
+\r
+ // run Groovy hook scripts\r
+ Set<String> scripts = new LinkedHashSet<String>();\r
+ scripts.addAll(gitblit.getPostReceiveScriptsInherited(repository));\r
+ if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {\r
+ scripts.addAll(repository.postReceiveScripts);\r
+ }\r
+ runGroovy(commands, scripts);\r
+ }\r
+\r
+ /**\r
+ * Log the ref changes in the container log.\r
+ *\r
+ * @param commands\r
+ */\r
+ protected void logRefChange(Collection<ReceiveCommand> commands) {\r
boolean isRefCreationOrDeletion = false;\r
\r
// log ref changes\r
if (isRefCreationOrDeletion) {\r
gitblit.resetRepositoryCache(repository.name);\r
}\r
+ }\r
\r
- if (repository.useIncrementalPushTags) {\r
- // tag each pushed branch tip\r
- String emailAddress = user.emailAddress == null ? rp.getRefLogIdent().getEmailAddress() : user.emailAddress;\r
- PersonIdent userIdent = new PersonIdent(user.getDisplayName(), emailAddress);\r
-\r
- for (ReceiveCommand cmd : commands) {\r
- if (!cmd.getRefName().startsWith(Constants.R_HEADS)) {\r
- // only tag branch ref changes\r
- continue;\r
- }\r
-\r
- if (!ReceiveCommand.Type.DELETE.equals(cmd.getType())\r
- && ReceiveCommand.Result.OK.equals(cmd.getResult())) {\r
- String objectId = cmd.getNewId().getName();\r
- String branch = cmd.getRefName().substring(Constants.R_HEADS.length());\r
- // get translation based on the server's locale setting\r
- String template = Translation.get("gb.incrementalPushTagMessage");\r
- String msg = MessageFormat.format(template, branch);\r
- String prefix;\r
- if (StringUtils.isEmpty(repository.incrementalPushTagPrefix)) {\r
- prefix = settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r");\r
- } else {\r
- prefix = repository.incrementalPushTagPrefix;\r
- }\r
-\r
- JGitUtils.createIncrementalRevisionTag(\r
- rp.getRepository(),\r
- objectId,\r
- userIdent,\r
- prefix,\r
- "0",\r
- msg);\r
- }\r
- }\r
+ /**\r
+ * Optionally update the incremental push tags.\r
+ *\r
+ * @param commands\r
+ */\r
+ protected void updateIncrementalPushTags(Collection<ReceiveCommand> commands) {\r
+ if (!repository.useIncrementalPushTags) {\r
+ return;\r
}\r
\r
- // update push log\r
- try {\r
- RefLogUtils.updateRefLog(user, rp.getRepository(), commands);\r
- LOGGER.debug(MessageFormat.format("{0} push log updated", repository.name));\r
- } catch (Exception e) {\r
- LOGGER.error(MessageFormat.format("Failed to update {0} pushlog", repository.name), e);\r
- }\r
+ // tag each pushed branch tip\r
+ String emailAddress = user.emailAddress == null ? getRefLogIdent().getEmailAddress() : user.emailAddress;\r
+ PersonIdent userIdent = new PersonIdent(user.getDisplayName(), emailAddress);\r
\r
- // check for updates pushed to the BranchTicketService branch\r
- // if the BranchTicketService is active it will reindex, as appropriate\r
for (ReceiveCommand cmd : commands) {\r
- if (Result.OK.equals(cmd.getResult())\r
- && BranchTicketService.BRANCH.equals(cmd.getRefName())) {\r
- rp.getRepository().fireEvent(new ReceiveCommandEvent(repository, cmd));\r
+ if (!cmd.getRefName().startsWith(Constants.R_HEADS)) {\r
+ // only tag branch ref changes\r
+ continue;\r
}\r
- }\r
\r
- // call post-receive plugins\r
- for (ReceiveHook hook : gitblit.getExtensions(ReceiveHook.class)) {\r
- try {\r
- hook.onPostReceive(this, commands);\r
- } catch (Exception e) {\r
- LOGGER.error("Failed to execute extension", e);\r
+ if (!ReceiveCommand.Type.DELETE.equals(cmd.getType())\r
+ && ReceiveCommand.Result.OK.equals(cmd.getResult())) {\r
+ String objectId = cmd.getNewId().getName();\r
+ String branch = cmd.getRefName().substring(Constants.R_HEADS.length());\r
+ // get translation based on the server's locale setting\r
+ String template = Translation.get("gb.incrementalPushTagMessage");\r
+ String msg = MessageFormat.format(template, branch);\r
+ String prefix;\r
+ if (StringUtils.isEmpty(repository.incrementalPushTagPrefix)) {\r
+ prefix = settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r");\r
+ } else {\r
+ prefix = repository.incrementalPushTagPrefix;\r
+ }\r
+\r
+ JGitUtils.createIncrementalRevisionTag(\r
+ getRepository(),\r
+ objectId,\r
+ userIdent,\r
+ prefix,\r
+ "0",\r
+ msg);\r
}\r
}\r
+ }\r
\r
- // run Groovy hook scripts\r
- Set<String> scripts = new LinkedHashSet<String>();\r
- scripts.addAll(gitblit.getPostReceiveScriptsInherited(repository));\r
- if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {\r
- scripts.addAll(repository.postReceiveScripts);\r
+ /**\r
+ * Update Gitblit's internal reflog.\r
+ *\r
+ * @param commands\r
+ */\r
+ protected void updateGitblitRefLog(Collection<ReceiveCommand> commands) {\r
+ try {\r
+ RefLogUtils.updateRefLog(user, getRepository(), commands);\r
+ LOGGER.debug(MessageFormat.format("{0} reflog updated", repository.name));\r
+ } catch (Exception e) {\r
+ LOGGER.error(MessageFormat.format("Failed to update {0} reflog", repository.name), e);\r
}\r
- runGroovy(commands, scripts);\r
}\r
\r
/** Execute commands to update references. */\r