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;
}
Aggregations