本文整理汇总了Java中org.eclipse.jgit.revwalk.RevTag类的典型用法代码示例。如果您正苦于以下问题:Java RevTag类的具体用法?Java RevTag怎么用?Java RevTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RevTag类属于org.eclipse.jgit.revwalk包,在下文中一共展示了RevTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testForCreateAnotationTag
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
@Test
public void testForCreateAnotationTag() throws GitAPIException, IOException {
Git git = Git.wrap(repository);
gitMgr.createTag(ws, "test", null, "test message", false);
List<Ref> refs = git.tagList().call();
assertEquals(1, refs.size());
assertEquals("refs/tags/test", refs.get(0).getName());
assertNotEquals(repository.resolve("HEAD"), refs.get(0).getObjectId());
RevWalk walk = new RevWalk(repository);
RevTag tag = walk.parseTag(refs.get(0).getObjectId());
assertEquals("test message", tag.getFullMessage());
}
示例2: fromRef
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
@Override
public ProposedTag fromRef(final Ref gitTag) throws SCMException {
notNull(gitTag, "gitTag");
final RevWalk walk = new RevWalk(getGit().getRepository());
final ObjectId tagId = gitTag.getObjectId();
JSONObject message;
try {
final RevTag tag = walk.parseTag(tagId);
message = (JSONObject) JSONValue.parse(tag.getFullMessage());
} catch (final IOException e) {
throw new SCMException(e, "Error while looking up tag because RevTag could not be parsed! Object-id was %s",
tagId);
} finally {
walk.dispose();
}
if (message == null) {
message = new JSONObject();
message.put(VERSION, "0");
message.put(BUILD_NUMBER, "0");
}
return new GitProposedTag(getGit(), log, gitTag, stripRefPrefix(gitTag.getName()), message,
config.getRemoteUrlOrNull());
}
示例3: fromRef
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
public static AnnotatedTag fromRef(Repository repository, Ref gitTag) throws IOException, IncorrectObjectTypeException {
Guard.notNull("gitTag", gitTag);
RevWalk walk = new RevWalk(repository);
JSONObject message;
try {
ObjectId tagId = gitTag.getObjectId();
RevTag tag = walk.parseTag(tagId);
message = (JSONObject) JSONValue.parse(tag.getFullMessage());
} finally {
walk.dispose();
}
if (message == null) {
message = new JSONObject();
message.put(VERSION, "0");
message.put(BUILD_NUMBER, "0");
}
return new AnnotatedTag(gitTag, stripRefPrefix(gitTag.getName()), message);
}
示例4: assertTag
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的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);
}
}
示例5: addToTags
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
private void addToTags(
final Map<String, Set<GitCommit>> commitsPerTag,
final String tagName,
final Date tagTime,
final List<GitTag> addTo,
final Map<String, RevTag> annotatedTagPerTagName) {
if (commitsPerTag.containsKey(tagName)) {
final Set<GitCommit> gitCommits = commitsPerTag.get(tagName);
final boolean isAnnotated = annotatedTagPerTagName.containsKey(tagName);
String annotation = null;
if (isAnnotated) {
annotation = annotatedTagPerTagName.get(tagName).getFullMessage();
}
final GitTag gitTag = new GitTag(tagName, annotation, newArrayList(gitCommits), tagTime);
addTo.add(gitTag);
}
}
示例6: getAnnotatedTagPerTagName
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
private Map<String, RevTag> getAnnotatedTagPerTagName(
final Optional<String> ignoreTagsIfNameMatches, final List<Ref> tagList) {
final Map<String, RevTag> tagPerCommit = newHashMap();
for (final Ref tag : tagList) {
if (ignoreTagsIfNameMatches.isPresent()) {
if (compile(ignoreTagsIfNameMatches.get()).matcher(tag.getName()).matches()) {
continue;
}
}
final Ref peeledTag = this.repository.peel(tag);
if (peeledTag.getPeeledObjectId() != null) {
try {
final RevTag revTag = RevTag.parse(this.repository.open(tag.getObjectId()).getBytes());
tagPerCommit.put(tag.getName(), revTag);
} catch (final IOException e) {
LOG.error(e.getMessage(), e);
}
}
}
return tagPerCommit;
}
示例7: internalGetDate
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的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;
}
示例8: getTime
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的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);
}
}
示例9: listObjects
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的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;
}
示例10: testParseTag
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
public void testParseTag() throws Exception {
RevCommit master = repo.branch("master").commit().create();
RevTag masterTag = repo.update("refs/tags/master-tag", repo.tag("master-tag", master));
RevTag masterTagTag = repo.update("refs/tags/master-tag-tag",
repo.tag("master-tag-tag", master));
assertEquals(new Result(
new Revision("master-tag", masterTag, OBJ_TAG, master, OBJ_COMMIT)),
parser.parse("master-tag"));
assertEquals(new Result(
new Revision("master-tag-tag", masterTagTag, OBJ_TAG, master, OBJ_COMMIT)),
parser.parse("master-tag-tag"));
RevBlob blob = repo.update("refs/tags/blob", repo.blob("blob"));
RevTag blobTag = repo.update("refs/tags/blob-tag", repo.tag("blob-tag", blob));
assertEquals(new Result(Revision.peeled("blob", blob)), parser.parse("blob"));
assertEquals(new Result(new Revision("blob-tag", blobTag, OBJ_TAG, blob, OBJ_BLOB)),
parser.parse("blob-tag"));
}
示例11: testFirstTagMissingTime
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
public void testFirstTagMissingTime() throws Exception {
RevCommit commit = repo.commit().create();
repo.tick(1);
RevTag tag = repo.tag("tag", commit);
repo.tick(1);
TagBuilder builder = new TagBuilder();
builder.setObjectId(tag);
builder.setTag("tagtag");
builder.setMessage("");
ObjectInserter ins = repo.getRepository().newObjectInserter();
ObjectId tagTagId;
try {
tagTagId = ins.insert(builder);
ins.flush();
} finally {
ins.release();
}
assertEquals(start + 1, getTime(commit));
assertEquals(start + 2, getTime(tag));
assertEquals(start + 2, getTime(tagTagId));
}
示例12: apply
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
Collection<TestResult> apply(ChangeApplicator applicator, String ... changeDescriptions) {
try {
final Collection<RevTag> matchingTags = findMatchingTags(changeDescriptions);
if (changeDescriptions.length != matchingTags.size()) {
throw new IllegalStateException("Unable to find all required changes " + Arrays.toString(changeDescriptions)
+ ", found only " + matchingTags.stream().map(tag -> tag.getTagName() + ": " + tag.getFullMessage()).collect(Collectors.toList()));
}
return applicator.apply(matchingTags);
} catch (GitAPIException e) {
throw new RuntimeException("Failed applying changes '" + Arrays.toString(changeDescriptions) + "'", e);
}
}
示例13: cherryPickTags
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
private Collection<TestResult> cherryPickTags(Collection<RevTag> tags) throws GitAPIException {
final Set<TestResult> combinedTestResults = new HashSet<>();
for (final RevTag tag : tags) {
final ObjectId tagId = tag.getObject().getId();
git.cherryPick().include(tagId).call();
combinedTestResults.addAll(testResultsExtractor.expectedTestResults(tagId));
}
return combinedTestResults;
}
示例14: applyLocallyFromTags
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
private Collection<TestResult> applyLocallyFromTags(Collection<RevTag> tags) throws GitAPIException {
final Set<TestResult> combinedTestResults = new HashSet<>();
final List<RevCommit> stashesToApply = new ArrayList<>();
stashesToApply.add(git.stashCreate().setIncludeUntracked(true).call());
for (final RevTag tag : tags) {
final ObjectId tagId = tag.getObject().getId();
git.cherryPick().setNoCommit(true).include(tagId).call();
stashesToApply.add(git.stashCreate().setIncludeUntracked(true).call());
combinedTestResults.addAll(testResultsExtractor.expectedTestResults(tagId));
}
applyStashChangesLocally(stashesToApply);
return combinedTestResults;
}
示例15: findMatchingTags
import org.eclipse.jgit.revwalk.RevTag; //导入依赖的package包/类
private Collection<RevTag> findMatchingTags(String[] changeDescriptions) throws GitAPIException {
final Set<String> changes = new HashSet<>(asList(changeDescriptions));
final RevWalk revWalk = new RevWalk(repository);
final List<RevTag> matchingTags = git.tagList().call().stream().map(ref -> {
try {
return revWalk.parseTag(ref.getObjectId());
} catch (IOException e) {
throw new RuntimeException("Unable to find tag for " + ref.getObjectId(), e);
}
}).filter(revTag -> changes.contains(revTag.getFullMessage().trim()))
.collect(Collectors.toList());
revWalk.dispose();
return matchingTags;
}