當前位置: 首頁>>代碼示例>>Java>>正文


Java Ref.getObjectId方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.lib.Ref.getObjectId方法的典型用法代碼示例。如果您正苦於以下問題:Java Ref.getObjectId方法的具體用法?Java Ref.getObjectId怎麽用?Java Ref.getObjectId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.lib.Ref的用法示例。


在下文中一共展示了Ref.getObjectId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDefaultBranch

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Nullable
public String getDefaultBranch() {
	if (defaultBranchOptional == null) {
		try {
			Ref headRef = getRepository().findRef("HEAD");
			if (headRef != null 
					&& headRef.isSymbolic() 
					&& headRef.getTarget().getName().startsWith(Constants.R_HEADS) 
					&& headRef.getObjectId() != null) {
				defaultBranchOptional = Optional.of(Repository.shortenRefName(headRef.getTarget().getName()));
			} else {
				defaultBranchOptional = Optional.absent();
			}
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	return defaultBranchOptional.orNull();
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:20,代碼來源:Project.java

示例2: getBranchObjectId

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
protected ObjectId getBranchObjectId(Git git) {
    Ref branchRef = null;
    try {
        String branchRevName = "refs/heads/" + branch;
        List<Ref> branches = git.branchList().call();
        for (Ref ref : branches) {
            String revName = ref.getName();
            if (Objects.equals(branchRevName, revName)) {
                branchRef = ref;
                break;
            }
        }
    } catch (GitAPIException e) {
        LOG.warn("Failed to find branches " + e, e);
    }

    ObjectId branchObjectId = null;
    if (branchRef != null) {
        branchObjectId = branchRef.getObjectId();
    }
    return branchObjectId;
}
 
開發者ID:fabric8io,項目名稱:fabric8-forge,代碼行數:23,代碼來源:RepositoryResource.java

示例3: fromRef

import org.eclipse.jgit.lib.Ref; //導入方法依賴的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());
}
 
開發者ID:SourcePond,項目名稱:release-maven-plugin-parent,代碼行數:25,代碼來源:GitRepository.java

示例4: fromRef

import org.eclipse.jgit.lib.Ref; //導入方法依賴的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);
}
 
開發者ID:danielflower,項目名稱:multi-module-maven-release-plugin,代碼行數:20,代碼來源:AnnotatedTag.java

示例5: getBranchObjectId

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
protected ObjectId getBranchObjectId(Git git, String branch) {
    Ref branchRef = null;
    try {
        String branchRevName = "refs/heads/" + branch;
        List<Ref> branches = git.branchList().call();
        for (Ref ref : branches) {
            String revName = ref.getName();
            if (Objects.equals(branchRevName, revName)) {
                branchRef = ref;
                break;
            }
        }
    } catch (GitAPIException e) {
        LOG.warn("Failed to find branches " + e, e);
    }

    ObjectId branchObjectId = null;
    if (branchRef != null) {
        branchObjectId = branchRef.getObjectId();
    }
    return branchObjectId;
}
 
開發者ID:fabric8io,項目名稱:fabric8-devops,代碼行數:23,代碼來源:GitBuildConfigProcessor.java

示例6: createBranchInfo

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
private BranchInfo createBranchInfo(
    PermissionBackend.ForRef perm,
    Ref ref,
    ProjectState projectState,
    CurrentUser user,
    Set<String> targets) {
  BranchInfo info = new BranchInfo();
  info.ref = ref.getName();
  info.revision = ref.getObjectId() != null ? ref.getObjectId().name() : null;
  info.canDelete =
      !targets.contains(ref.getName()) && perm.testOrFalse(RefPermission.DELETE) ? true : null;

  BranchResource rsrc = new BranchResource(projectState, user, ref);
  for (UiAction.Description d : uiActions.from(branchViews, rsrc)) {
    if (info.actions == null) {
      info.actions = new TreeMap<>();
    }
    info.actions.put(d.getId(), new ActionInfo(d));
  }

  List<WebLinkInfo> links = webLinks.getBranchLinks(projectState.getName(), ref.getName());
  info.webLinks = links.isEmpty() ? null : links;
  return info;
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:25,代碼來源:ListBranches.java

示例7: assertTag

import org.eclipse.jgit.lib.Ref; //導入方法依賴的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);
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:25,代碼來源:SubmitOnPushIT.java

示例8: initChangeRefMaps

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
private void initChangeRefMaps() {
  if (refsByChange == null) {
    int estRefsPerChange = 4;
    refsById = MultimapBuilder.hashKeys().arrayListValues().build();
    refsByChange =
        MultimapBuilder.hashKeys(allRefs().size() / estRefsPerChange)
            .arrayListValues(estRefsPerChange)
            .build();
    for (Ref ref : allRefs().values()) {
      ObjectId obj = ref.getObjectId();
      if (obj != null) {
        PatchSet.Id psId = PatchSet.Id.fromRef(ref.getName());
        if (psId != null) {
          refsById.put(obj, ref);
          refsByChange.put(psId.getParentKey(), ref);
        }
      }
    }
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:21,代碼來源:ReceiveCommits.java

示例9: call

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
public RefUpdate.Result call() throws Exception {
  Ref ref = repo.exactRef(refName);
  afterReadRef.run();
  ObjectId oldId;
  if (ref == null) {
    oldId = ObjectId.zeroId();
  } else {
    oldId = ref.getObjectId();
    int next = parse(rw, oldId);
    if (next >= value) {
      // a concurrent write updated the ref already to this or a higher value
      return RefUpdate.Result.NO_CHANGE;
    }
  }
  return store(repo, rw, oldId, value);
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:18,代碼來源:RepoSequence.java

示例10: countCommits

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public int countCommits(Repository repository, String branch) throws Exception {
	RevWalk walk = new RevWalk(repository);
	try {
		Ref ref = repository.findRef(REMOTE_REFS_PREFIX + branch);
		ObjectId objectId = ref.getObjectId();
		RevCommit start = walk.parseCommit(objectId);
		walk.setRevFilter(RevFilter.NO_MERGES);
		return RevWalkUtils.count(walk, start, null);
	} finally {
		walk.dispose();
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:13,代碼來源:GitHelper.java

示例11: countCommits

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
@Override
public int countCommits(Repository repository, String branch) throws Exception {
	RevWalk walk = new RevWalk(repository);
	try {
		Ref ref = repository.findRef(REMOTE_REFS_PREFIX + branch);
		ObjectId objectId = ref.getObjectId();
		RevCommit start = walk.parseCommit(objectId);
		walk.setRevFilter(RevFilter.NO_MERGES);
		return RevWalkUtils.count(walk, start, null);
	} finally {
		walk.dispose();
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:14,代碼來源:GitServiceImpl.java

示例12: hasAtLeastOneReference

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
/**
 * Checks if a repo has been cloned correctly.
 *
 * @param repo
 *     to check
 *
 * @return true if has been cloned correctly, false otherwise
 */
public boolean hasAtLeastOneReference(Repository repo) {

    for (Ref ref : repo.getAllRefs().values()) {
        if (ref.getObjectId() == null)
            continue;
        return true;
    }

    return false;
}
 
開發者ID:arquillian,項目名稱:arquillian-algeron,代碼行數:19,代碼來源:GitOperations.java

示例13: updateProjectRef

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public static void updateProjectRef(ObjectId treeId, ObjectInserter objectInserter, Repository repository, CurrentUser currentUser)
        throws IOException, NoFilepatternException, GitAPIException {
    // Create a branch
    Ref gerritCiRef = repository.getRef("refs/meta/gerrit-ci");
    CommitBuilder commitBuilder = new CommitBuilder();
    commitBuilder.setTreeId(treeId);
    logger.info("treeId: " + treeId);

    if (gerritCiRef != null) {
        ObjectId prevCommit = gerritCiRef.getObjectId();
        logger.info("prevCommit: " + prevCommit);
        commitBuilder.setParentId(prevCommit);
    }
    // build commit
    logger.info("Adding git tree : " + treeId);
    commitBuilder.setMessage("Modify project build rules.");
    final IdentifiedUser iUser = (IdentifiedUser) currentUser;
    PersonIdent user = new PersonIdent(currentUser.getUserName(), iUser.getEmailAddresses().iterator().next());
    commitBuilder.setAuthor(user);
    commitBuilder.setCommitter(user);
    ObjectId commitId = objectInserter.insert(commitBuilder);
    objectInserter.flush();
    logger.info(" Making new commit: " + commitId);
    RefUpdate newRef = repository.updateRef("refs/meta/gerrit-ci");
    newRef.setNewObjectId(commitId);
    newRef.update();
    repository.close();
}
 
開發者ID:palantir,項目名稱:gerrit-ci,代碼行數:29,代碼來源:JobsServlet.java

示例14: getPeeled

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
private ObjectId getPeeled(final Ref tag) {
  final Ref peeledTag = this.repository.peel(tag);
  if (peeledTag.getPeeledObjectId() != null) {
    return peeledTag.getPeeledObjectId();
  } else {
    return tag.getObjectId();
  }
}
 
開發者ID:tomasbjerre,項目名稱:git-changelog-lib,代碼行數:9,代碼來源:GitRepo.java

示例15: getObjectId

import org.eclipse.jgit.lib.Ref; //導入方法依賴的package包/類
public ObjectId getObjectId(Account.Id accountId, Change.Id changeId) {
  try (Repository repo = repoManager.openRepository(allUsers)) {
    Ref ref = repo.exactRef(RefNames.refsStarredChanges(changeId, accountId));
    return ref != null ? ref.getObjectId() : ObjectId.zeroId();
  } catch (IOException e) {
    log.error(
        String.format(
            "Getting star object ID for account %d on change %d failed",
            accountId.get(), changeId.get()),
        e);
    return ObjectId.zeroId();
  }
}
 
開發者ID:gerrit-review,項目名稱:gerrit,代碼行數:14,代碼來源:StarredChangesUtil.java


注:本文中的org.eclipse.jgit.lib.Ref.getObjectId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。