Search in sources :

Example 1 with IncludeRule

use of jetbrains.buildServer.vcs.IncludeRule in project teamcity-git by JetBrains.

the class SubmoduleAwareTreeIterator method movedToEntry.

/**
 * Move iterator to the specific entry.
 *
 * @throws CorruptObjectException in case of submodule processing problem
 */
protected void movedToEntry() throws CorruptObjectException {
    myIsEof = eof();
    if (myIsEof) {
        return;
    }
    int wrappedMode = myWrappedIterator.getEntryRawMode();
    String entryPath = myWrappedIterator.getEntryPathString();
    myIsOnSubmodule = checkoutSubmodules() && GITLINK_MODE_BITS == wrappedMode;
    if (myIsOnSubmodule && myRules != null) {
        // if submodule dir is excluded by checkout rules we can treat it as an empty dir
        String pathFromRoot = getPathFromRoot(entryPath);
        if (myRules.map(pathFromRoot) == null) {
            // submodule dir itself is excluded, but some of its dirs can be included
            // happens with checkout rules like +:submodule/dir1
            boolean rulesInsideSubmodule = false;
            CheckoutRules submoduleAsRule = new CheckoutRules("+:" + pathFromRoot);
            for (IncludeRule rule : myRules.getRootIncludeRules()) {
                if (submoduleAsRule.map(rule.getFrom()) != null) {
                    rulesInsideSubmodule = true;
                    break;
                }
            }
            if (!rulesInsideSubmodule) {
                myIsOnSubmodule = false;
            }
        }
    }
    mode = myIsOnSubmodule ? TREE_MODE_BITS : wrappedMode;
    if (myIsOnSubmodule) {
        try {
            mySubmoduleCommit = getSubmoduleCommit(entryPath, myWrappedIterator.getEntryObjectId());
        } catch (Exception e) {
            if (mySubmodulesPolicy.isIgnoreSubmodulesErrors()) {
                if (myLogSubmoduleErrors)
                    LOG.warn("Ignore submodule error for SHA " + ObjectId.toString(myWrappedIterator.getEntryObjectId()) + ": \"" + e.getMessage() + "\". It seems to be fixed in one of the later commits.");
                mySubmoduleCommit = null;
                myIsOnSubmodule = false;
                mySubmoduleError = true;
                mode = wrappedMode;
            } else {
                if (e instanceof CorruptObjectException) {
                    throw (CorruptObjectException) e;
                } else {
                    CorruptObjectException ex = new CorruptObjectException(myWrappedIterator.getEntryObjectId(), e.getMessage());
                    ex.initCause(e);
                    throw ex;
                }
            }
        }
        if (myIdBuffer == null) {
            myIdBuffer = new byte[Constants.OBJECT_ID_LENGTH];
        }
        if (mySubmoduleCommit != null) {
            mySubmoduleCommit.getTree().getId().copyRawTo(myIdBuffer, 0);
        }
    } else {
        mySubmoduleCommit = null;
    }
    // copy name
    final int nameLength = myWrappedIterator.getNameLength();
    final int pathLength = nameLength + pathOffset;
    ensurePathCapacity(pathLength, pathOffset);
    myWrappedIterator.getName(path, pathOffset);
    pathLen = pathLength;
}
Also used : CorruptObjectException(org.eclipse.jgit.errors.CorruptObjectException) CheckoutRules(jetbrains.buildServer.vcs.CheckoutRules) IncludeRule(jetbrains.buildServer.vcs.IncludeRule) CorruptObjectException(org.eclipse.jgit.errors.CorruptObjectException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) TransportException(org.eclipse.jgit.errors.TransportException) VcsAuthenticationException(jetbrains.buildServer.buildTriggers.vcs.git.VcsAuthenticationException) VcsException(jetbrains.buildServer.vcs.VcsException) SubmoduleFetchException(jetbrains.buildServer.buildTriggers.vcs.git.submodules.SubmoduleFetchException)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 VcsAuthenticationException (jetbrains.buildServer.buildTriggers.vcs.git.VcsAuthenticationException)1 SubmoduleFetchException (jetbrains.buildServer.buildTriggers.vcs.git.submodules.SubmoduleFetchException)1 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)1 IncludeRule (jetbrains.buildServer.vcs.IncludeRule)1 VcsException (jetbrains.buildServer.vcs.VcsException)1 CorruptObjectException (org.eclipse.jgit.errors.CorruptObjectException)1 TransportException (org.eclipse.jgit.errors.TransportException)1