use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ExternalIdIT method insertNonParsableExternalIds.
private Set<ConsistencyProblemInfo> insertNonParsableExternalIds() throws IOException {
MutableInteger i = new MutableInteger();
String scheme = "corrupt";
Set<ConsistencyProblemInfo> expectedProblems = new HashSet<>();
try (Repository repo = repoManager.openRepository(allUsers);
RevWalk rw = new RevWalk(repo)) {
String externalId = nextId(scheme, i);
String noteId = insertExternalIdWithoutAccountId(repo, rw, externalId);
expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': Value for 'externalId." + externalId + ".accountId' is missing, expected account ID"));
externalId = nextId(scheme, i);
noteId = insertExternalIdWithKeyThatDoesntMatchNoteId(repo, rw, externalId);
expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': SHA1 of external ID '" + externalId + "' does not match note ID '" + noteId + "'"));
noteId = insertExternalIdWithInvalidConfig(repo, rw, nextId(scheme, i));
expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': Invalid line in config file"));
noteId = insertExternalIdWithEmptyNote(repo, rw, nextId(scheme, i));
expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': Expected exactly 1 'externalId' section, found 0"));
}
return expectedProblems;
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ChangeIndexRewriter method rewriteImpl.
private Predicate<ChangeData> rewriteImpl(Predicate<ChangeData> in, QueryOptions opts) throws QueryParseException {
ChangeIndex index = indexes.getSearchIndex();
MutableInteger leafTerms = new MutableInteger();
Predicate<ChangeData> out = rewriteImpl(in, index, opts, leafTerms);
if (in == out || out instanceof IndexPredicate) {
return new IndexedChangeQuery(index, out, opts);
} else if (out == null) /* cannot rewrite */
{
return in;
} else {
return out;
}
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ChangeNoteUtil method parseParentNumber.
private static Integer parseParentNumber(byte[] note, MutableInteger curr, Change.Id changeId) throws ConfigInvalidException {
checkHeaderLineFormat(note, curr, PARENT_NUMBER, changeId);
int start = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1;
MutableInteger i = new MutableInteger();
int parentNumber = RawParseUtils.parseBase10(note, start, i);
int endOfLine = RawParseUtils.nextLF(note, curr.value);
if (i.value != endOfLine - 1) {
throw parseException(changeId, "could not parse %s", PARENT_NUMBER);
}
checkResult(parentNumber, "parent number", changeId);
curr.value = endOfLine;
return Integer.valueOf(parentNumber);
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ChangeNoteUtil method parseCommentLength.
private static int parseCommentLength(byte[] note, MutableInteger curr, Change.Id changeId) throws ConfigInvalidException {
checkHeaderLineFormat(note, curr, LENGTH, changeId);
int startOfLength = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1;
MutableInteger i = new MutableInteger();
i.value = startOfLength;
int commentLength = RawParseUtils.parseBase10(note, startOfLength, i);
if (i.value == startOfLength) {
throw parseException(changeId, "could not parse %s", LENGTH);
}
int endOfLine = RawParseUtils.nextLF(note, curr.value);
if (i.value != endOfLine - 1) {
throw parseException(changeId, "could not parse %s", LENGTH);
}
curr.value = endOfLine;
return checkResult(commentLength, "comment length", changeId);
}
use of org.eclipse.jgit.util.MutableInteger in project gerrit by GerritCodeReview.
the class ChangeNoteUtil method parsePsId.
private static PatchSet.Id parsePsId(byte[] note, MutableInteger curr, Change.Id changeId, String fieldName) throws ConfigInvalidException {
checkHeaderLineFormat(note, curr, fieldName, changeId);
int startOfPsId = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1;
MutableInteger i = new MutableInteger();
int patchSetId = RawParseUtils.parseBase10(note, startOfPsId, i);
int endOfLine = RawParseUtils.nextLF(note, curr.value);
if (i.value != endOfLine - 1) {
throw parseException(changeId, "could not parse %s", fieldName);
}
checkResult(patchSetId, "patchset id", changeId);
curr.value = endOfLine;
return new PatchSet.Id(changeId, patchSetId);
}
Aggregations