org.eclipse.jgit.lib.Ref.getName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.eclipse.jgit.lib.Ref.getName方法的一些代码示例,展示了Ref.getName的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ref.getName方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Ref
类名称:Ref
方法名:getName

Ref.getName介绍

[英]What this ref is called within the repository.
[中]

代码示例

代码示例来源:origin: gocd/gocd

  1. Ref getBranch(String branchName) throws GitAPIException {
  2. List<Ref> branches = getAllBranches();
  3. for (Ref branch : branches) {
  4. if (branch.getName().endsWith(branchName)) {
  5. return branch;
  6. }
  7. }
  8. return null;
  9. }

代码示例来源:origin: spring-cloud/spring-cloud-config

  1. private boolean containsBranch(Git git, String label, ListMode listMode)
  2. throws GitAPIException {
  3. ListBranchCommand command = git.branchList();
  4. if (listMode != null) {
  5. command.setListMode(listMode);
  6. }
  7. List<Ref> branches = command.call();
  8. for (Ref ref : branches) {
  9. if (ref.getName().endsWith("/" + label)) {
  10. return true;
  11. }
  12. }
  13. return false;
  14. }

代码示例来源:origin: gocd/gocd

  1. public Long commitCountOnMaster() throws GitAPIException, IncorrectObjectTypeException, MissingObjectException {
  2. // not inside a doLocked/synchronized block because we don't want to block the server status service.
  3. // we do a `git branch` because we switch branches as part of normal git operations,
  4. // and we don't care about number of commits on those branches.
  5. List<Ref> branches = git.branchList().call();
  6. for (Ref branch : branches) {
  7. if (branch.getName().equals("refs/heads/master")) {
  8. Iterable<RevCommit> commits = git.log().add(branch.getObjectId()).call();
  9. long count = 0;
  10. for (RevCommit commit : commits) {
  11. count++;
  12. }
  13. return count;
  14. }
  15. }
  16. return Long.valueOf(-1);
  17. }
  18. }

代码示例来源:origin: gocd/gocd

  1. @Test
  2. public void shouldBeOnMasterAndTemporaryBranchesDeletedAfterGettingMergeConfig() throws Exception {
  3. String original = "first\nsecond\n";
  4. String nextUpdate = "1st\nsecond\n";
  5. String latestUpdate = "first\nsecond\nthird\n";
  6. configRepo.checkin(goConfigRevision(original, "md5-1"));
  7. configRepo.checkin(goConfigRevision(nextUpdate, "md5-2"));
  8. RevCommit currentRevCommitOnMaster = configRepo.getCurrentRevCommit();
  9. String mergedConfig = configRepo.getConfigMergedWithLatestRevision(goConfigRevision(latestUpdate, "md5-3"), "md5-1");
  10. assertThat(mergedConfig, is("1st\nsecond\nthird\n"));
  11. List<Ref> branches = getAllBranches();
  12. assertThat(branches.size(), is(1));
  13. assertThat(branches.get(0).getName().endsWith("master"), is(true));
  14. assertThat(configRepo.getCurrentRevCommit(), is(currentRevCommitOnMaster));
  15. }

代码示例来源:origin: gocd/gocd

  1. @Test
  2. public void shouldThrowExceptionWhenThereIsMergeConflict() throws Exception {
  3. String original = "first\nsecond\n";
  4. String nextUpdate = "1st\nsecond\n";
  5. String latestUpdate = "2nd\nsecond\n";
  6. configRepo.checkin(goConfigRevision(original, "md5-1"));
  7. configRepo.checkin(goConfigRevision(nextUpdate, "md5-2"));
  8. RevCommit currentRevCommitOnMaster = configRepo.getCurrentRevCommit();
  9. try {
  10. configRepo.getConfigMergedWithLatestRevision(goConfigRevision(latestUpdate, "md5-3"), "md5-1");
  11. fail("should have bombed for merge conflict");
  12. } catch (ConfigMergeException e) {
  13. assertThat(e.getMessage(), is(ConfigFileHasChangedException.CONFIG_CHANGED_PLEASE_REFRESH));
  14. }
  15. List<Ref> branches = getAllBranches();
  16. assertThat(branches.size(), is(1));
  17. assertThat(branches.get(0).getName().endsWith("master"), is(true));
  18. assertThat(configRepo.getCurrentRevCommit(), is(currentRevCommitOnMaster));
  19. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. @Override
  2. public int compare(Ref o1, Ref o2) {
  3. return o1.getName().compareTo(o2.getName());
  4. }
  5. });

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /**
  2. * Compare a reference to a name.
  3. *
  4. * @param o1
  5. * the reference instance.
  6. * @param o2
  7. * the name to compare to.
  8. * @return standard Comparator result of &lt; 0, 0, &gt; 0.
  9. */
  10. public static int compareTo(Ref o1, String o2) {
  11. return o1.getName().compareTo(o2);
  12. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. int kind(Ref r) {
  2. if (r.getName().startsWith(R_TAGS))
  3. return 0;
  4. if (r.getName().startsWith(R_HEADS))
  5. return 1;
  6. if (r.getName().startsWith(R_REMOTES))
  7. return 2;
  8. return 3;
  9. }
  10. }

代码示例来源:origin: jphp-group/jphp

  1. public static ArrayMemory valueOf(Ref ref) {
  2. ArrayMemory memory = new ArrayMemory();
  3. memory.refOfIndex("name").assign(ref.getName());
  4. memory.refOfIndex("peeled").assign(ref.isPeeled());
  5. memory.refOfIndex("symbolic").assign(ref.isSymbolic());
  6. memory.refOfIndex("objectId").assign(valueOf(ref.getObjectId()));
  7. memory.refOfIndex("storage").assign(valueOf(ref.getStorage()));
  8. return memory;
  9. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /**
  2. * Get the name of the ref this update will operate on.
  3. *
  4. * @return name of underlying ref.
  5. */
  6. public String getName() {
  7. return getRef().getName();
  8. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /**
  2. * Add a reference to push.
  3. *
  4. * @param ref
  5. * the source reference. The remote name will match.
  6. * @return {@code this}.
  7. */
  8. public PushCommand add(Ref ref) {
  9. refSpecs.add(new RefSpec(ref.getLeaf().getName()));
  10. return this;
  11. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. private String longDescription(Ref tag, int depth, ObjectId tip)
  2. throws IOException {
  3. return String.format(
  4. "%s-%d-g%s", tag.getName().substring(R_TAGS.length()), //$NON-NLS-1$
  5. Integer.valueOf(depth), w.getObjectReader().abbreviate(tip)
  6. .name());
  7. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /**
  2. * Does this specification's destination description match the ref?
  3. *
  4. * @param r
  5. * ref whose name should be tested.
  6. * @return true if the names match; false otherwise.
  7. */
  8. public boolean matchDestination(Ref r) {
  9. return match(r.getName(), getDestination());
  10. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /** {@inheritDoc} */
  2. @Override
  3. public ReflogReader getReflogReader(String refName) throws IOException {
  4. Ref ref = findRef(refName);
  5. if (ref != null)
  6. return new ReflogReaderImpl(this, ref.getName());
  7. return null;
  8. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. private String calculateOurName(Ref headRef) {
  2. if (ourCommitName != null)
  3. return ourCommitName;
  4. String targetRefName = headRef.getTarget().getName();
  5. String headName = Repository.shortenRefName(targetRefName);
  6. return headName;
  7. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. private String calculateOurName(Ref headRef) {
  2. if (ourCommitName != null)
  3. return ourCommitName;
  4. String targetRefName = headRef.getTarget().getName();
  5. String headName = Repository.shortenRefName(targetRefName);
  6. return headName;
  7. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. private static boolean equals(Ref r1, Ref r2) {
  2. if (r1 == null || r2 == null) {
  3. return false;
  4. }
  5. if (r1.isSymbolic()) {
  6. return r2.isSymbolic() && r1.getTarget().getName()
  7. .equals(r2.getTarget().getName());
  8. }
  9. return !r2.isSymbolic()
  10. && Objects.equals(r1.getObjectId(), r2.getObjectId());
  11. }

代码示例来源:origin: centic9/jgit-cookbook

  1. public static void main(String[] args) throws IOException {
  2. try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
  3. // the Ref holds an ObjectId for any type of object (tree, commit, blob, tree)
  4. Ref head = repository.exactRef("refs/heads/master");
  5. System.out.println("Ref of refs/heads/master: " + head + ": " + head.getName() + " - " + head.getObjectId().getName());
  6. }
  7. }
  8. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /** {@inheritDoc} */
  2. @Override
  3. protected Result doDelete(Result desiredResult) throws IOException {
  4. if (getRefDatabase().compareAndRemove(dstRef)) {
  5. getRefDatabase().removed(dstRef.getName());
  6. return desiredResult;
  7. }
  8. return Result.LOCK_FAILURE;
  9. }

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. private static String getHeadName(Ref head) {
  2. String headName;
  3. if (head.isSymbolic()) {
  4. headName = head.getTarget().getName();
  5. } else {
  6. ObjectId headId = head.getObjectId();
  7. // the callers are checking this already
  8. assert headId != null;
  9. headName = headId.getName();
  10. }
  11. return headName;
  12. }

相关文章