Java Code Examples for org.eclipse.jgit.lib.Constants#OBJ_TAG

The following examples show how to use org.eclipse.jgit.lib.Constants#OBJ_TAG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RevWalk.java    From onedev with MIT License 6 votes vote down vote up
/**
 * Locate a reference to any object without loading it.
 * <p>
 * The object may or may not exist in the repository. It is impossible to
 * tell from this method's return value.
 *
 * @param id
 *            name of the object.
 * @param type
 *            type of the object. Must be a valid Git object type.
 * @return reference to the object. Never null.
 */
@NonNull
public RevObject lookupAny(AnyObjectId id, int type) {
	RevObject r = objects.get(id);
	if (r == null) {
		switch (type) {
		case Constants.OBJ_COMMIT:
			r = createCommit(id);
			break;
		case Constants.OBJ_TREE:
			r = new RevTree(id);
			break;
		case Constants.OBJ_BLOB:
			r = new RevBlob(id);
			break;
		case Constants.OBJ_TAG:
			r = new RevTag(id);
			break;
		default:
			throw new IllegalArgumentException(MessageFormat.format(
					JGitText.get().invalidGitType, Integer.valueOf(type)));
		}
		objects.add(r);
	}
	return r;
}
 
Example 2
Source File: GitTag.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private GitObjectType getType (RevObject object) {
    GitObjectType objType = GitObjectType.UNKNOWN;
    if (object != null) {
        switch (object.getType()) {
            case Constants.OBJ_COMMIT:
                objType = GitObjectType.COMMIT;
                break;
            case Constants.OBJ_BLOB:
                objType = GitObjectType.BLOB;
                break;
            case Constants.OBJ_TAG:
                objType = GitObjectType.TAG;
                break;
            case Constants.OBJ_TREE:
                objType = GitObjectType.TREE;
                break;
        }
    }
    return objType;
}
 
Example 3
Source File: RevWalk.java    From onedev with MIT License 5 votes vote down vote up
private RevObject parseNew(AnyObjectId id, ObjectLoader ldr)
		throws LargeObjectException, CorruptObjectException,
		MissingObjectException, IOException {
	RevObject r;
	int type = ldr.getType();
	switch (type) {
	case Constants.OBJ_COMMIT: {
		final RevCommit c = createCommit(id);
		c.parseCanonical(this, getCachedBytes(c, ldr));
		r = c;
		break;
	}
	case Constants.OBJ_TREE: {
		r = new RevTree(id);
		r.flags |= PARSED;
		break;
	}
	case Constants.OBJ_BLOB: {
		r = new RevBlob(id);
		r.flags |= PARSED;
		break;
	}
	case Constants.OBJ_TAG: {
		final RevTag t = new RevTag(id);
		t.parseCanonical(this, getCachedBytes(t, ldr));
		r = t;
		break;
	}
	default:
		throw new IllegalArgumentException(MessageFormat.format(
				JGitText.get().badObjectType, Integer.valueOf(type)));
	}
	objects.add(r);
	return r;
}
 
Example 4
Source File: RevTag.java    From onedev with MIT License 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public final int getType() {
	return Constants.OBJ_TAG;
}