org.locationtech.geogig.model.Ref.localName()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(169)

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

Ref.localName介绍

暂无

代码示例

代码示例来源:origin: locationtech/geogig

  1. /**
  2. * @return the name for this ref with the prefix removed
  3. */
  4. public String localName() {
  5. return localName(name);
  6. }

代码示例来源:origin: org.locationtech.geogig/geogig-api

  1. /**
  2. * @return the name for this ref with the prefix removed
  3. */
  4. public String localName() {
  5. return localName(name);
  6. }

代码示例来源:origin: locationtech/geogig

  1. @Override
  2. public boolean apply(String name) {
  3. return Ref.localName(name).equals(mappedBranchName);
  4. }};

代码示例来源:origin: org.locationtech.geogig/geogig-cli

  1. private String refDisplayString(Ref ref) {
  2. String branchName = ref.getName();
  3. if (branchName.startsWith(Ref.HEADS_PREFIX)) {
  4. branchName = ref.localName();
  5. } else if (branchName.startsWith(Ref.REMOTES_PREFIX)) {
  6. branchName = branchName.substring(Ref.REMOTES_PREFIX.length());
  7. }
  8. if (ref instanceof SymRef) {
  9. branchName += " -> " + Ref.localName(((SymRef) ref).getTarget());
  10. }
  11. return branchName;
  12. }
  13. }

代码示例来源:origin: locationtech/geogig

  1. private String refDisplayString(Ref ref) {
  2. String branchName = ref.getName();
  3. if (branchName.startsWith(Ref.HEADS_PREFIX)) {
  4. branchName = ref.localName();
  5. } else if (branchName.startsWith(Ref.REMOTES_PREFIX)) {
  6. branchName = branchName.substring(Ref.REMOTES_PREFIX.length());
  7. }
  8. if (ref instanceof SymRef) {
  9. branchName += " -> " + Ref.localName(((SymRef) ref).getTarget());
  10. }
  11. return branchName;
  12. }
  13. }

代码示例来源:origin: org.locationtech.geogig/geogig-cli-core

  1. private String refDisplayString(Ref ref) {
  2. String branchName = ref.getName();
  3. if (branchName.startsWith(Ref.HEADS_PREFIX)) {
  4. branchName = ref.localName();
  5. } else if (branchName.startsWith(Ref.REMOTES_PREFIX)) {
  6. branchName = branchName.substring(Ref.REMOTES_PREFIX.length());
  7. }
  8. if (ref instanceof SymRef) {
  9. branchName += " -> " + Ref.localName(((SymRef) ref).getTarget());
  10. }
  11. return branchName;
  12. }
  13. }

代码示例来源:origin: locationtech/geogig

  1. public List<BranchConfig> getAll() {
  2. List<BranchConfig> configs = new ArrayList<>();
  3. final Map<String, String> all = configDatabase().getAll();
  4. for (Ref branch : command(BranchListOp.class).call()) {
  5. final String section = String.format("branches.%s", branch.localName());
  6. final String remoteKey = String.format("%s.%s", section, "remote");
  7. final String remoteBranchKey = String.format("%s.%s", section, "merge");
  8. final String descriptionKey = String.format("%s.%s", section, "description");
  9. String remoteName = all.get(remoteKey);
  10. String remoteBranch = all.get(remoteBranchKey);
  11. String description = all.get(descriptionKey);
  12. BranchConfig config = BranchConfig.builder()//
  13. .branch(branch)//
  14. .remoteName(Optional.ofNullable(remoteName))//
  15. .remoteBranch(Optional.ofNullable(remoteBranch))//
  16. .description(Optional.ofNullable(description))//
  17. .build();
  18. configs.add(config);
  19. }
  20. return configs;
  21. }

代码示例来源:origin: org.locationtech.geogig/geogig-remoting

  1. private Ref toLocal(Ref localRemoteRef) {
  2. final Remote remote = this.remote;
  3. if (localRemoteRef.namespace().equals(Ref.TAGS_PREFIX)) {
  4. return localRemoteRef;
  5. }
  6. final String localName = localRemoteRef.localName();
  7. final String remoteNamespace = localRemoteRef.namespace();
  8. final String expectedRemotePrefix = Ref.REMOTES_PREFIX + remote.getName() + "/";
  9. Preconditions.checkArgument(remoteNamespace.equals(expectedRemotePrefix));
  10. final String localPrefix = Ref.HEAD.equals(localName) ? "" : Ref.HEADS_PREFIX;
  11. final String localRefName = localPrefix + localName;
  12. Ref ref = null;
  13. if (localRemoteRef instanceof SymRef) {
  14. SymRef sr = (SymRef) localRemoteRef;
  15. Ref localTarget = toLocal(new Ref(sr.getTarget(), sr.getObjectId()));
  16. ref = new SymRef(localRefName, localTarget);
  17. } else {
  18. ref = new Ref(localRefName, localRemoteRef.getObjectId());
  19. }
  20. return ref;
  21. }

代码示例来源:origin: locationtech/geogig

  1. public TestData branch(String newBranch) {
  2. Ref ref = getContext().command(BranchCreateOp.class).setName(newBranch).call();
  3. checkState(newBranch.equals(ref.localName()));
  4. return this;
  5. }

代码示例来源:origin: org.locationtech.geogig/geogig-core

  1. public TestData branch(String newBranch) {
  2. Ref ref = getContext().command(BranchCreateOp.class).setName(newBranch).call();
  3. checkState(newBranch.equals(ref.localName()));
  4. return this;
  5. }

代码示例来源:origin: org.locationtech.geogig/geogig-remoting

  1. private Ref toRemote(Ref localRef) {
  2. if (localRef.namespace().equals(Ref.TAGS_PREFIX)) {
  3. return localRef;
  4. }
  5. checkArgument(!localRef.getName().startsWith(Ref.REMOTES_PREFIX),
  6. "ref is already in a remotes namespace: %s", localRef);
  7. final String remoteNamespace = Ref.REMOTES_PREFIX + remote.getName() + "/";
  8. final String remoteRefName = remoteNamespace + localRef.localName();
  9. Ref remoteRef;
  10. if (localRef instanceof SymRef) {
  11. SymRef sr = (SymRef) localRef;
  12. String localtarget = sr.getTarget();
  13. Ref remoteTarget = toRemote(new Ref(localtarget, sr.getObjectId()));
  14. remoteRef = new SymRef(remoteRefName, remoteTarget);
  15. } else {
  16. remoteRef = new Ref(remoteRefName, localRef.getObjectId());
  17. }
  18. return remoteRef;
  19. }

代码示例来源:origin: org.locationtech.geogig/geogig-web-api

  1. public void writeBranchCreateResponse(Ref createdBranch) throws StreamWriterException {
  2. out.writeStartElement("BranchCreated");
  3. writeElement("name", createdBranch.localName());
  4. writeElement("source", createdBranch.getObjectId().toString());
  5. out.writeEndElement(); // End BranchCreated
  6. }

代码示例来源:origin: locationtech/geogig

  1. private void verifyBranchConfig(Repository remote, Repository clone) {
  2. ImmutableList<Ref> remoteBranches = remote.command(BranchListOp.class).call();
  3. for (Ref remoteBranch : remoteBranches) {
  4. BranchConfig config = clone.command(BranchConfigOp.class)
  5. .setName(remoteBranch.localName()).get();
  6. assertEquals(remoteBranch.localName(), config.getBranch().localName());
  7. assertEquals("origin", config.getRemoteName().get());
  8. assertEquals(remoteBranch.getName(), config.getRemoteBranch().get());
  9. }
  10. }

代码示例来源:origin: org.locationtech.geogig/geogig-web-api

  1. @Override
  2. public void write(ResponseWriter writer) throws Exception {
  3. writer.start();
  4. if (!currHead.isPresent()) {
  5. writer.writeErrors("Repository has no HEAD.");
  6. } else {
  7. if (currHead.get() instanceof SymRef) {
  8. final SymRef headRef = (SymRef) currHead.get();
  9. writer.writeHeaderElements("branch", Ref.localName(headRef.getTarget()));
  10. }
  11. }
  12. writer.writeStaged(geogig.command(DiffIndex.class).addFilter(pathFilter), offset,
  13. limit);
  14. writer.writeUnstaged(geogig.command(DiffWorkTree.class).setFilter(pathFilter),
  15. offset, limit);
  16. writer.writeUnmerged(geogig.command(ConflictsQueryOp.class).call(), offset, limit);
  17. writer.finish();
  18. }
  19. });

代码示例来源:origin: locationtech/geogig

  1. /**
  2. * Executes the status command using the provided options.
  3. */
  4. @Override
  5. public void runInternal(GeogigCLI cli) throws IOException {
  6. checkParameter(limit >= 0, "Limit must be 0 or greater.");
  7. Console console = cli.getConsole();
  8. GeoGIG geogig = cli.getGeogig();
  9. StatusOp op = geogig.command(StatusOp.class).setReportLimit(limit);
  10. StatusSummary summary = op.call();
  11. final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
  12. checkParameter(currHead.isPresent(), "Repository has no HEAD.");
  13. if (currHead.get() instanceof SymRef) {
  14. final SymRef headRef = (SymRef) currHead.get();
  15. console.println("# On branch " + Ref.localName(headRef.getTarget()));
  16. } else {
  17. console.println("# Not currently on any branch.");
  18. }
  19. print(console, summary);
  20. }

代码示例来源:origin: org.locationtech.geogig/geogig-cli-core

  1. /**
  2. * Executes the status command using the provided options.
  3. */
  4. @Override
  5. public void runInternal(GeogigCLI cli) throws IOException {
  6. checkParameter(limit >= 0, "Limit must be 0 or greater.");
  7. Console console = cli.getConsole();
  8. GeoGIG geogig = cli.getGeogig();
  9. StatusOp op = geogig.command(StatusOp.class).setReportLimit(limit);
  10. StatusSummary summary = op.call();
  11. final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
  12. checkParameter(currHead.isPresent(), "Repository has no HEAD.");
  13. if (currHead.get() instanceof SymRef) {
  14. final SymRef headRef = (SymRef) currHead.get();
  15. console.println("# On branch " + Ref.localName(headRef.getTarget()));
  16. } else {
  17. console.println("# Not currently on any branch.");
  18. }
  19. print(console, summary);
  20. }

代码示例来源:origin: org.locationtech.geogig/geogig-cli

  1. /**
  2. * Executes the status command using the provided options.
  3. */
  4. @Override
  5. public void runInternal(GeogigCLI cli) throws IOException {
  6. checkParameter(limit >= 0, "Limit must be 0 or greater.");
  7. Console console = cli.getConsole();
  8. GeoGIG geogig = cli.getGeogig();
  9. StatusOp op = geogig.command(StatusOp.class).setReportLimit(limit);
  10. StatusSummary summary = op.call();
  11. final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
  12. checkParameter(currHead.isPresent(), "Repository has no HEAD.");
  13. if (currHead.get() instanceof SymRef) {
  14. final SymRef headRef = (SymRef) currHead.get();
  15. console.println("# On branch " + Ref.localName(headRef.getTarget()));
  16. } else {
  17. console.println("# Not currently on any branch.");
  18. }
  19. print(console, summary);
  20. }

代码示例来源:origin: locationtech/geogig

  1. public TestData checkout(String branch) {
  2. getContext().command(CheckoutOp.class).setSource(branch).call();
  3. Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get();
  4. if (head instanceof SymRef) {
  5. String target = ((SymRef) head).getTarget();
  6. head = getContext().command(RefParse.class).setName(target).call().get();
  7. }
  8. String headBranch = head.localName();
  9. checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch);
  10. return this;
  11. }

代码示例来源:origin: org.locationtech.geogig/geogig-core

  1. public TestData checkout(String branch) {
  2. getContext().command(CheckoutOp.class).setSource(branch).call();
  3. Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get();
  4. if (head instanceof SymRef) {
  5. String target = ((SymRef) head).getTarget();
  6. head = getContext().command(RefParse.class).setName(target).call().get();
  7. }
  8. String headBranch = head.localName();
  9. checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch);
  10. return this;
  11. }

代码示例来源:origin: locationtech/geogig

  1. @Test
  2. public void testConstructor() throws Exception {
  3. Ref testRef = new Ref(Ref.REFS_PREFIX + "commit1", oid);
  4. assertEquals(Ref.REFS_PREFIX + "commit1", testRef.getName());
  5. assertEquals(Ref.REFS_PREFIX, testRef.namespace());
  6. assertEquals("commit1", testRef.localName());
  7. assertEquals(oid, testRef.getObjectId());
  8. }

相关文章