本文整理匯總了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();
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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();
}
示例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();
}
}
示例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();
}
}