James Moger
2014-05-23 c51db7be8f6f48ddebff5053915be68f77e3fc94
Merged #85 "Tag server-side merges when incremental push tags are enabled"
3 files modified
102 ■■■■■ changed files
releases.moxie 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/git/GitblitReceivePack.java 92 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/git/PatchsetReceivePack.java 8 ●●●● patch | view | raw | blame | history
releases.moxie
@@ -34,6 +34,7 @@
    - Add object type (ot) parameter for RSS queries to retrieve tag details (pr-165, ticket-66)
    - Add setting to allow STARTTLS without requiring SMTPS (pr-183)
    - Added an extension point for monitoring onStartup and onShutdown (ticket-79)
    - Tag server-side merges when incremental push tags are enabled (issue-432, ticket-85)
    dependencyChanges:
    - Update to javax.mail 1.5.1 (issue-417, ticket-58)
    contributors:
@@ -45,6 +46,7 @@
    - Berke Viktor
    - Marcus Hunger
    - Matthias Cullmann
    - Emmeran Seehuber
    settings:
    - { name: 'web.allowDeletingNonEmptyRepositories', defaultValue: 'true' }
    - { name: 'mail.starttls', defaultValue: 'false' }
src/main/java/com/gitblit/git/GitblitReceivePack.java
@@ -331,6 +331,43 @@
            return;
        }
        logRefChange(commands);
        updateIncrementalPushTags(commands);
        updateGitblitRefLog(commands);
        // check for updates pushed to the BranchTicketService branch
        // if the BranchTicketService is active it will reindex, as appropriate
        for (ReceiveCommand cmd : commands) {
            if (Result.OK.equals(cmd.getResult())
                    && BranchTicketService.BRANCH.equals(cmd.getRefName())) {
                rp.getRepository().fireEvent(new ReceiveCommandEvent(repository, cmd));
            }
        }
        // call post-receive plugins
        for (ReceiveHook hook : gitblit.getExtensions(ReceiveHook.class)) {
            try {
                hook.onPostReceive(this, commands);
            } catch (Exception e) {
                LOGGER.error("Failed to execute extension", e);
            }
        }
        // run Groovy hook scripts
        Set<String> scripts = new LinkedHashSet<String>();
        scripts.addAll(gitblit.getPostReceiveScriptsInherited(repository));
        if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
            scripts.addAll(repository.postReceiveScripts);
        }
        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
@@ -362,10 +399,20 @@
        if (isRefCreationOrDeletion) {
            gitblit.resetRepositoryCache(repository.name);
        }
    }
        if (repository.useIncrementalPushTags) {
    /**
     * 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 ? rp.getRefLogIdent().getEmailAddress() : user.emailAddress;
        String emailAddress = user.emailAddress == null ? getRefLogIdent().getEmailAddress() : user.emailAddress;
            PersonIdent userIdent = new PersonIdent(user.getDisplayName(), emailAddress);
            for (ReceiveCommand cmd : commands) {
@@ -389,7 +436,7 @@
                    }
                    JGitUtils.createIncrementalRevisionTag(
                            rp.getRepository(),
                        getRepository(),
                            objectId,
                            userIdent,
                            prefix,
@@ -399,39 +446,18 @@
            }
        }
        // update push log
    /**
     * Update Gitblit's internal reflog.
     *
     * @param commands
     */
    protected void updateGitblitRefLog(Collection<ReceiveCommand> commands) {
        try {
            RefLogUtils.updateRefLog(user, rp.getRepository(), commands);
            LOGGER.debug(MessageFormat.format("{0} push log updated", repository.name));
            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} pushlog", repository.name), e);
            LOGGER.error(MessageFormat.format("Failed to update {0} reflog", repository.name), e);
        }
        // check for updates pushed to the BranchTicketService branch
        // if the BranchTicketService is active it will reindex, as appropriate
        for (ReceiveCommand cmd : commands) {
            if (Result.OK.equals(cmd.getResult())
                    && BranchTicketService.BRANCH.equals(cmd.getRefName())) {
                rp.getRepository().fireEvent(new ReceiveCommandEvent(repository, cmd));
            }
        }
        // call post-receive plugins
        for (ReceiveHook hook : gitblit.getExtensions(ReceiveHook.class)) {
            try {
                hook.onPostReceive(this, commands);
            } catch (Exception e) {
                LOGGER.error("Failed to execute extension", e);
            }
        }
        // run Groovy hook scripts
        Set<String> scripts = new LinkedHashSet<String>();
        scripts.addAll(gitblit.getPostReceiveScriptsInherited(repository));
        if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
            scripts.addAll(repository.postReceiveScripts);
        }
        runGroovy(commands, scripts);
    }
    /** Execute commands to update references. */
src/main/java/com/gitblit/git/PatchsetReceivePack.java
@@ -1202,11 +1202,15 @@
        if (ticket != null) {
            ticketNotifier.queueMailing(ticket);
            // update the reflog with the merge
            if (oldRef != null) {
                ReceiveCommand cmd = new ReceiveCommand(oldRef.getObjectId(),
                        ObjectId.fromString(mergeResult.sha), oldRef.getName());
                RefLogUtils.updateRefLog(user, getRepository(), Arrays.asList(cmd));
                cmd.setResult(Result.OK);
                List<ReceiveCommand> commands = Arrays.asList(cmd);
                logRefChange(commands);
                updateIncrementalPushTags(commands);
                updateGitblitRefLog(commands);
            }
            // call patchset hooks