本文整理汇总了Java中org.eclipse.jgit.revwalk.RevObject类的典型用法代码示例。如果您正苦于以下问题:Java RevObject类的具体用法?Java RevObject怎么用?Java RevObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RevObject类属于org.eclipse.jgit.revwalk包,在下文中一共展示了RevObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
@Override
protected void run () throws GitException {
Repository repository = getRepository();
try {
RevObject obj = Utils.findObject(repository, taggedObject);
TagCommand cmd = new Git(repository).tag();
cmd.setName(tagName);
cmd.setForceUpdate(forceUpdate);
cmd.setObjectId(obj);
cmd.setAnnotated(message != null && !message.isEmpty() || signed);
if (cmd.isAnnotated()) {
cmd.setMessage(message);
cmd.setSigned(signed);
}
cmd.call();
ListTagCommand tagCmd = new ListTagCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
tagCmd.run();
Map<String, GitTag> tags = tagCmd.getTags();
tag = tags.get(tagName);
} catch (JGitInternalException | GitAPIException ex) {
throw new GitException(ex);
}
}
示例2: getType
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
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;
}
示例3: getRevCommit
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
private RevCommit getRevCommit(RevWalk revWalk, ObjectId objectId)
throws MissingObjectException, IOException {
RevCommit revCommit = null;
RevObject revObject = revWalk.parseAny(objectId);
int type = revObject.getType();
// 'git tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]
// <tagname> [<commit> | <object>]
//
// <commit> | <object>
// The object that the new tag will refer to, usually a commit.
// Defaults to HEAD.
//
if (Constants.OBJ_COMMIT == type) {
revCommit = RevCommit.class.cast(revObject);
}
return revCommit;
}
示例4: getCommitId
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
@Override
public ObjectId getCommitId() {
org.eclipse.jgit.lib.Ref jgitRef = getJgitRef();
ObjectId objectId = jgitRef.getPeeledObjectId();
if (objectId == null) {
objectId = jgitRef.getObjectId();
}
GitRepository gitRepository = getGitRepository();
RevWalk revWalk = new RevWalk(gitRepository.getObjectReader());
try {
RevObject revObject = revWalk.parseAny(objectId);
if (Constants.OBJ_COMMIT != revObject.getType()) {
objectId = null;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return objectId;
}
示例5: createAllCommitsRevWalk
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
private RevWalk createAllCommitsRevWalk(CommitSelection commitSelection)
throws IOException, MissingObjectException,
IncorrectObjectTypeException {
RevWalk revWalk = new RevWalk(repository);
RefDatabase refDatabase = repository.getRefDatabase();
Map<String, org.eclipse.jgit.lib.Ref> refs = refDatabase.getRefs("");
for (Entry<String, Ref> entryRef : refs.entrySet()) {
ObjectId refObject = entryRef.getValue().getObjectId();
RevObject revObject = revWalk.parseAny(refObject);
if (revObject instanceof RevCommit) {
revWalk.markStart((RevCommit) revObject);
}
}
revWalk.setRevFilter(new CommitSelectionRevFilter(commitSelection));
revWalk.sort(RevSort.REVERSE);
revWalk.sort(RevSort.TOPO, true);
return revWalk;
}
示例6: isCommit
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
private boolean isCommit(ReceiveCommand cmd) {
RevObject obj;
try {
obj = rp.getRevWalk().parseAny(cmd.getNewId());
} catch (IOException err) {
logError("Invalid object " + cmd.getNewId().name() + " for " + cmd.getRefName(), err);
reject(cmd, "invalid object");
return false;
}
if (obj instanceof RevCommit) {
return true;
}
reject(cmd, "not a commit");
return false;
}
示例7: assertTag
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
private void assertTag(Project.NameKey project, String branch, PushOneCommit.Tag tag)
throws Exception {
try (Repository repo = repoManager.openRepository(project)) {
Ref tagRef = repo.findRef(tag.name);
assertThat(tagRef).isNotNull();
ObjectId taggedCommit = null;
if (tag instanceof PushOneCommit.AnnotatedTag) {
PushOneCommit.AnnotatedTag annotatedTag = (PushOneCommit.AnnotatedTag) tag;
try (RevWalk rw = new RevWalk(repo)) {
RevObject object = rw.parseAny(tagRef.getObjectId());
assertThat(object).isInstanceOf(RevTag.class);
RevTag tagObject = (RevTag) object;
assertThat(tagObject.getFullMessage()).isEqualTo(annotatedTag.message);
assertThat(tagObject.getTaggerIdent()).isEqualTo(annotatedTag.tagger);
taggedCommit = tagObject.getObject();
}
} else {
taggedCommit = tagRef.getObjectId();
}
ObjectId headCommit = repo.exactRef(branch).getObjectId();
assertThat(taggedCommit).isNotNull();
assertThat(taggedCommit).isEqualTo(headCommit);
}
}
示例8: expectToHaveSubmoduleState
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
protected void expectToHaveSubmoduleState(
TestRepository<?> repo, String branch, String submodule, ObjectId expectedId)
throws Exception {
submodule = name(submodule);
ObjectId commitId =
repo.git()
.fetch()
.setRemote("origin")
.call()
.getAdvertisedRef("refs/heads/" + branch)
.getObjectId();
RevWalk rw = repo.getRevWalk();
RevCommit c = rw.parseCommit(commitId);
rw.parseBody(c.getTree());
RevTree tree = c.getTree();
RevObject actualId = repo.get(tree, submodule);
assertThat(actualId).isEqualTo(expectedId);
}
示例9: createTag
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
/**
* creates a tag in a repository
*
* @param repository
* @param objectId
* , the ref the tag points towards
* @param tagger
* , the person tagging the object
* @param tag
* , the string label
* @param message
* , the string message
* @return boolean, true if operation was successful, otherwise false
*/
public static boolean createTag(Repository repository, String objectId, PersonIdent tagger, String tag, String message) {
try {
Git gitClient = Git.open(repository.getDirectory());
TagCommand tagCommand = gitClient.tag();
tagCommand.setTagger(tagger);
tagCommand.setMessage(message);
if (objectId != null) {
RevObject revObj = getCommit(repository, objectId);
tagCommand.setObjectId(revObj);
}
tagCommand.setName(tag);
Ref call = tagCommand.call();
return call != null ? true : false;
} catch (Exception e) {
error(e, repository, "Failed to create tag {1} in repository {0}", objectId, tag);
}
return false;
}
示例10: internalGetDate
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
private Date internalGetDate(RevObject referencedObject) {
Date date = new Date(0);
if (referencedObject != null) {
if (referencedObject instanceof RevTag) {
RevTag tag = (RevTag) referencedObject;
PersonIdent tagger = tag.getTaggerIdent();
if (tagger != null) {
date = tagger.getWhen();
}
} else if (referencedObject instanceof RevCommit) {
RevCommit commit = (RevCommit) referencedObject;
date = JGitUtils.getAuthorDate(commit);
}
}
return date;
}
示例11: getTime
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
Long getTime(final RevWalk walk, final ObjectId id) throws IOException {
try {
return cache.get(id, new Callable<Long>() {
@Override
public Long call() throws IOException {
RevObject o = walk.parseAny(id);
while (o instanceof RevTag) {
RevTag tag = (RevTag) o;
PersonIdent ident = tag.getTaggerIdent();
if (ident != null) {
return ident.getWhen().getTime() / 1000;
}
o = tag.getObject();
walk.parseHeaders(o);
}
if (o.getType() == Constants.OBJ_COMMIT) {
return Long.valueOf(((RevCommit) o).getCommitTime());
}
return Long.MIN_VALUE;
}
});
} catch (ExecutionException e) {
Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
throw new IOException(e);
}
}
示例12: listObjects
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
static List<RevObject> listObjects(RevWalk walk, Revision rev)
throws MissingObjectException, IOException {
List<RevObject> objects = Lists.newArrayListWithExpectedSize(1);
ObjectId id = rev.getId();
RevObject cur;
while (true) {
cur = walk.parseAny(id);
objects.add(cur);
if (cur.getType() != Constants.OBJ_TAG) {
break;
}
id = ((RevTag) cur).getObject();
}
if (cur.getType() == Constants.OBJ_COMMIT) {
objects.add(walk.parseTree(((RevCommit) cur).getTree()));
}
return objects;
}
示例13: createTag
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
/**
* creates a tag in a repository
*
* @param repository
* @param objectId, the ref the tag points towards
* @param tagger, the person tagging the object
* @param tag, the string label
* @param message, the string message
* @return boolean, true if operation was successful, otherwise false
*/
public static boolean createTag(Repository repository, String objectId, PersonIdent tagger, String tag, String message) {
try {
Git gitClient = Git.open(repository.getDirectory());
TagCommand tagCommand = gitClient.tag();
tagCommand.setTagger(tagger);
tagCommand.setMessage(message);
if (objectId != null) {
RevObject revObj = getCommit(repository, objectId);
tagCommand.setObjectId(revObj);
}
tagCommand.setName(tag);
Ref call = tagCommand.call();
return call != null ? true : false;
} catch (Exception e) {
error(e, repository, "Failed to create tag {1} in repository {0}", objectId, tag);
}
return false;
}
示例14: lsTree
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
/** {@inheritDoc} */
@Deprecated
public List<IndexEntry> lsTree(String treeIsh, boolean recursive) throws GitException, InterruptedException {
try (Repository repo = getRepository();
ObjectReader or = repo.newObjectReader();
RevWalk w = new RevWalk(or)) {
TreeWalk tree = new TreeWalk(or);
tree.addTree(w.parseTree(repo.resolve(treeIsh)));
tree.setRecursive(recursive);
List<IndexEntry> r = new ArrayList<>();
while (tree.next()) {
RevObject rev = w.parseAny(tree.getObjectId(0));
r.add(new IndexEntry(
String.format("%06o", tree.getRawMode(0)),
typeString(rev.getType()),
tree.getObjectId(0).name(),
tree.getNameString()));
}
return r;
} catch (IOException e) {
throw new GitException(e);
}
}
示例15: main
import org.eclipse.jgit.revwalk.RevObject; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
// a RevWalk allows to retrieve information from the repository
try (RevWalk walk = new RevWalk(repository)) {
// a simple tag that is not annotated
Ref simpleTag = repository.findRef("initialtag");
RevObject any = walk.parseAny(simpleTag.getObjectId());
System.out.println("Commit: " + any);
// an annotated tag
Ref annotatedTag = repository.findRef("secondtag");
any = walk.parseAny(annotatedTag.getObjectId());
System.out.println("Tag: " + any);
// finally try to print out the tag-content
System.out.println("\nTag-Content: \n");
ObjectLoader loader = repository.open(annotatedTag.getObjectId());
loader.copyTo(System.out);
walk.dispose();
}
}
}