| | |
| | | setAllowDeletes(user.canDeleteRef(repository));
|
| | | setAllowNonFastForwards(user.canRewindRef(repository));
|
| | |
|
| | | int maxObjectSz = settings.getInteger(Keys.git.maxObjectSizeLimit, -1);
|
| | | if (maxObjectSz >= 0) {
|
| | | setMaxObjectSizeLimit(maxObjectSz);
|
| | | }
|
| | | int maxPackSz = settings.getInteger(Keys.git.maxPackSizeLimit, -1);
|
| | | if (maxPackSz >= 0) {
|
| | | setMaxPackSizeLimit(maxPackSz);
|
| | | }
|
| | | setCheckReceivedObjects(settings.getBoolean(Keys.git.checkReceivedObjects, true));
|
| | | setCheckReferencedObjectsAreReachable(settings.getBoolean(Keys.git.checkReferencedObjectsAreReachable, true));
|
| | |
|
| | | // setup pre and post receive hook
|
| | | setPreReceiveHook(this);
|
| | | setPostReceiveHook(this);
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // log ref changes
|
| | | for (ReceiveCommand cmd : commands) {
|
| | |
|
| | | if (Result.OK.equals(cmd.getResult())) {
|
| | | // add some logging for important ref changes
|
| | | switch (cmd.getType()) {
|
| | | case DELETE:
|
| | | LOGGER.info(MessageFormat.format("{0} DELETED {1} in {2} ({3})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name()));
|
| | | break;
|
| | | case CREATE:
|
| | | LOGGER.info(MessageFormat.format("{0} CREATED {1} in {2}", user.username, cmd.getRefName(), repository.name));
|
| | | break;
|
| | | case UPDATE:
|
| | | LOGGER.info(MessageFormat.format("{0} UPDATED {1} in {2} (from {3} to {4})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name(), cmd.getNewId().name()));
|
| | | break;
|
| | | case UPDATE_NONFASTFORWARD:
|
| | | LOGGER.info(MessageFormat.format("{0} UPDATED NON-FAST-FORWARD {1} in {2} (from {3} to {4})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name(), cmd.getNewId().name()));
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (repository.useIncrementalPushTags) {
|
| | | // tag each pushed branch tip
|
| | | String emailAddress = user.emailAddress == null ? rp.getRefLogIdent().getEmailAddress() : user.emailAddress;
|
| | | PersonIdent userIdent = new PersonIdent(user.getDisplayName(), emailAddress);
|
| | |
|
| | | for (ReceiveCommand cmd : commands) {
|
| | | if (!cmd.getRefName().startsWith(Constants.R_HEADS)) {
|
| | | // only tag branch ref changes
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (!ReceiveCommand.Type.DELETE.equals(cmd.getType())
|
| | | && ReceiveCommand.Result.OK.equals(cmd.getResult())) {
|
| | | String objectId = cmd.getNewId().getName();
|
| | | String branch = cmd.getRefName().substring(Constants.R_HEADS.length());
|
| | | // get translation based on the server's locale setting
|
| | | String template = Translation.get("gb.incrementalPushTagMessage");
|
| | | String msg = MessageFormat.format(template, branch);
|
| | | String prefix;
|
| | | if (StringUtils.isEmpty(repository.incrementalPushTagPrefix)) {
|
| | | prefix = settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r");
|
| | | } else {
|
| | | prefix = repository.incrementalPushTagPrefix;
|
| | | }
|
| | |
|
| | | JGitUtils.createIncrementalRevisionTag(
|
| | | rp.getRepository(),
|
| | | objectId,
|
| | | userIdent,
|
| | | prefix,
|
| | | "0",
|
| | | msg);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // update push log
|
| | | try {
|
| | | RefLogUtils.updateRefLog(user, rp.getRepository(), commands);
|
| | | LOGGER.debug(MessageFormat.format("{0} push log updated", repository.name));
|
| | | } catch (Exception e) {
|
| | | LOGGER.error(MessageFormat.format("Failed to update {0} pushlog", repository.name), e);
|
| | | }
|
| | | logRefChange(commands);
|
| | | updateIncrementalPushTags(commands);
|
| | | updateGitblitRefLog(commands);
|
| | |
|
| | | // check for updates pushed to the BranchTicketService branch
|
| | | // if the BranchTicketService is active it will reindex, as appropriate
|
| | |
| | | runGroovy(commands, scripts);
|
| | | }
|
| | |
|
| | | /**
|
| | | * Log the ref changes in the container log.
|
| | | *
|
| | | * @param commands
|
| | | */
|
| | | protected void logRefChange(Collection<ReceiveCommand> commands) {
|
| | | boolean isRefCreationOrDeletion = false;
|
| | |
|
| | | // log ref changes
|
| | | for (ReceiveCommand cmd : commands) {
|
| | |
|
| | | if (Result.OK.equals(cmd.getResult())) {
|
| | | // add some logging for important ref changes
|
| | | switch (cmd.getType()) {
|
| | | case DELETE:
|
| | | LOGGER.info(MessageFormat.format("{0} DELETED {1} in {2} ({3})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name()));
|
| | | isRefCreationOrDeletion = true;
|
| | | break;
|
| | | case CREATE:
|
| | | LOGGER.info(MessageFormat.format("{0} CREATED {1} in {2}", user.username, cmd.getRefName(), repository.name));
|
| | | isRefCreationOrDeletion = true;
|
| | | break;
|
| | | case UPDATE:
|
| | | LOGGER.info(MessageFormat.format("{0} UPDATED {1} in {2} (from {3} to {4})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name(), cmd.getNewId().name()));
|
| | | break;
|
| | | case UPDATE_NONFASTFORWARD:
|
| | | LOGGER.info(MessageFormat.format("{0} UPDATED NON-FAST-FORWARD {1} in {2} (from {3} to {4})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name(), cmd.getNewId().name()));
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (isRefCreationOrDeletion) {
|
| | | gitblit.resetRepositoryCache(repository.name);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * Optionally update the incremental push tags.
|
| | | *
|
| | | * @param commands
|
| | | */
|
| | | protected void updateIncrementalPushTags(Collection<ReceiveCommand> commands) {
|
| | | if (!repository.useIncrementalPushTags) {
|
| | | return;
|
| | | }
|
| | |
|
| | | // tag each pushed branch tip
|
| | | String emailAddress = user.emailAddress == null ? getRefLogIdent().getEmailAddress() : user.emailAddress;
|
| | | PersonIdent userIdent = new PersonIdent(user.getDisplayName(), emailAddress);
|
| | |
|
| | | for (ReceiveCommand cmd : commands) {
|
| | | if (!cmd.getRefName().startsWith(Constants.R_HEADS)) {
|
| | | // only tag branch ref changes
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (!ReceiveCommand.Type.DELETE.equals(cmd.getType())
|
| | | && ReceiveCommand.Result.OK.equals(cmd.getResult())) {
|
| | | String objectId = cmd.getNewId().getName();
|
| | | String branch = cmd.getRefName().substring(Constants.R_HEADS.length());
|
| | | // get translation based on the server's locale setting
|
| | | String template = Translation.get("gb.incrementalPushTagMessage");
|
| | | String msg = MessageFormat.format(template, branch);
|
| | | String prefix;
|
| | | if (StringUtils.isEmpty(repository.incrementalPushTagPrefix)) {
|
| | | prefix = settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r");
|
| | | } else {
|
| | | prefix = repository.incrementalPushTagPrefix;
|
| | | }
|
| | |
|
| | | JGitUtils.createIncrementalRevisionTag(
|
| | | getRepository(),
|
| | | objectId,
|
| | | userIdent,
|
| | | prefix,
|
| | | "0",
|
| | | msg);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * Update Gitblit's internal reflog.
|
| | | *
|
| | | * @param commands
|
| | | */
|
| | | protected void updateGitblitRefLog(Collection<ReceiveCommand> commands) {
|
| | | try {
|
| | | RefLogUtils.updateRefLog(user, getRepository(), commands);
|
| | | LOGGER.debug(MessageFormat.format("{0} reflog updated", repository.name));
|
| | | } catch (Exception e) {
|
| | | LOGGER.error(MessageFormat.format("Failed to update {0} reflog", repository.name), e);
|
| | | }
|
| | | }
|
| | |
|
| | | /** Execute commands to update references. */
|
| | | @Override
|
| | | protected void executeCommands() {
|