本文整理了Java中org.locationtech.geogig.model.Ref.localName
方法的一些代码示例,展示了Ref.localName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ref.localName
方法的具体详情如下:
包路径:org.locationtech.geogig.model.Ref
类名称:Ref
方法名:localName
暂无
代码示例来源:origin: locationtech/geogig
/**
* @return the name for this ref with the prefix removed
*/
public String localName() {
return localName(name);
}
代码示例来源:origin: org.locationtech.geogig/geogig-api
/**
* @return the name for this ref with the prefix removed
*/
public String localName() {
return localName(name);
}
代码示例来源:origin: locationtech/geogig
@Override
public boolean apply(String name) {
return Ref.localName(name).equals(mappedBranchName);
}};
代码示例来源:origin: org.locationtech.geogig/geogig-cli
private String refDisplayString(Ref ref) {
String branchName = ref.getName();
if (branchName.startsWith(Ref.HEADS_PREFIX)) {
branchName = ref.localName();
} else if (branchName.startsWith(Ref.REMOTES_PREFIX)) {
branchName = branchName.substring(Ref.REMOTES_PREFIX.length());
}
if (ref instanceof SymRef) {
branchName += " -> " + Ref.localName(((SymRef) ref).getTarget());
}
return branchName;
}
}
代码示例来源:origin: locationtech/geogig
private String refDisplayString(Ref ref) {
String branchName = ref.getName();
if (branchName.startsWith(Ref.HEADS_PREFIX)) {
branchName = ref.localName();
} else if (branchName.startsWith(Ref.REMOTES_PREFIX)) {
branchName = branchName.substring(Ref.REMOTES_PREFIX.length());
}
if (ref instanceof SymRef) {
branchName += " -> " + Ref.localName(((SymRef) ref).getTarget());
}
return branchName;
}
}
代码示例来源:origin: org.locationtech.geogig/geogig-cli-core
private String refDisplayString(Ref ref) {
String branchName = ref.getName();
if (branchName.startsWith(Ref.HEADS_PREFIX)) {
branchName = ref.localName();
} else if (branchName.startsWith(Ref.REMOTES_PREFIX)) {
branchName = branchName.substring(Ref.REMOTES_PREFIX.length());
}
if (ref instanceof SymRef) {
branchName += " -> " + Ref.localName(((SymRef) ref).getTarget());
}
return branchName;
}
}
代码示例来源:origin: locationtech/geogig
public List<BranchConfig> getAll() {
List<BranchConfig> configs = new ArrayList<>();
final Map<String, String> all = configDatabase().getAll();
for (Ref branch : command(BranchListOp.class).call()) {
final String section = String.format("branches.%s", branch.localName());
final String remoteKey = String.format("%s.%s", section, "remote");
final String remoteBranchKey = String.format("%s.%s", section, "merge");
final String descriptionKey = String.format("%s.%s", section, "description");
String remoteName = all.get(remoteKey);
String remoteBranch = all.get(remoteBranchKey);
String description = all.get(descriptionKey);
BranchConfig config = BranchConfig.builder()//
.branch(branch)//
.remoteName(Optional.ofNullable(remoteName))//
.remoteBranch(Optional.ofNullable(remoteBranch))//
.description(Optional.ofNullable(description))//
.build();
configs.add(config);
}
return configs;
}
代码示例来源:origin: org.locationtech.geogig/geogig-remoting
private Ref toLocal(Ref localRemoteRef) {
final Remote remote = this.remote;
if (localRemoteRef.namespace().equals(Ref.TAGS_PREFIX)) {
return localRemoteRef;
}
final String localName = localRemoteRef.localName();
final String remoteNamespace = localRemoteRef.namespace();
final String expectedRemotePrefix = Ref.REMOTES_PREFIX + remote.getName() + "/";
Preconditions.checkArgument(remoteNamespace.equals(expectedRemotePrefix));
final String localPrefix = Ref.HEAD.equals(localName) ? "" : Ref.HEADS_PREFIX;
final String localRefName = localPrefix + localName;
Ref ref = null;
if (localRemoteRef instanceof SymRef) {
SymRef sr = (SymRef) localRemoteRef;
Ref localTarget = toLocal(new Ref(sr.getTarget(), sr.getObjectId()));
ref = new SymRef(localRefName, localTarget);
} else {
ref = new Ref(localRefName, localRemoteRef.getObjectId());
}
return ref;
}
代码示例来源:origin: locationtech/geogig
public TestData branch(String newBranch) {
Ref ref = getContext().command(BranchCreateOp.class).setName(newBranch).call();
checkState(newBranch.equals(ref.localName()));
return this;
}
代码示例来源:origin: org.locationtech.geogig/geogig-core
public TestData branch(String newBranch) {
Ref ref = getContext().command(BranchCreateOp.class).setName(newBranch).call();
checkState(newBranch.equals(ref.localName()));
return this;
}
代码示例来源:origin: org.locationtech.geogig/geogig-remoting
private Ref toRemote(Ref localRef) {
if (localRef.namespace().equals(Ref.TAGS_PREFIX)) {
return localRef;
}
checkArgument(!localRef.getName().startsWith(Ref.REMOTES_PREFIX),
"ref is already in a remotes namespace: %s", localRef);
final String remoteNamespace = Ref.REMOTES_PREFIX + remote.getName() + "/";
final String remoteRefName = remoteNamespace + localRef.localName();
Ref remoteRef;
if (localRef instanceof SymRef) {
SymRef sr = (SymRef) localRef;
String localtarget = sr.getTarget();
Ref remoteTarget = toRemote(new Ref(localtarget, sr.getObjectId()));
remoteRef = new SymRef(remoteRefName, remoteTarget);
} else {
remoteRef = new Ref(remoteRefName, localRef.getObjectId());
}
return remoteRef;
}
代码示例来源:origin: org.locationtech.geogig/geogig-web-api
public void writeBranchCreateResponse(Ref createdBranch) throws StreamWriterException {
out.writeStartElement("BranchCreated");
writeElement("name", createdBranch.localName());
writeElement("source", createdBranch.getObjectId().toString());
out.writeEndElement(); // End BranchCreated
}
代码示例来源:origin: locationtech/geogig
private void verifyBranchConfig(Repository remote, Repository clone) {
ImmutableList<Ref> remoteBranches = remote.command(BranchListOp.class).call();
for (Ref remoteBranch : remoteBranches) {
BranchConfig config = clone.command(BranchConfigOp.class)
.setName(remoteBranch.localName()).get();
assertEquals(remoteBranch.localName(), config.getBranch().localName());
assertEquals("origin", config.getRemoteName().get());
assertEquals(remoteBranch.getName(), config.getRemoteBranch().get());
}
}
代码示例来源:origin: org.locationtech.geogig/geogig-web-api
@Override
public void write(ResponseWriter writer) throws Exception {
writer.start();
if (!currHead.isPresent()) {
writer.writeErrors("Repository has no HEAD.");
} else {
if (currHead.get() instanceof SymRef) {
final SymRef headRef = (SymRef) currHead.get();
writer.writeHeaderElements("branch", Ref.localName(headRef.getTarget()));
}
}
writer.writeStaged(geogig.command(DiffIndex.class).addFilter(pathFilter), offset,
limit);
writer.writeUnstaged(geogig.command(DiffWorkTree.class).setFilter(pathFilter),
offset, limit);
writer.writeUnmerged(geogig.command(ConflictsQueryOp.class).call(), offset, limit);
writer.finish();
}
});
代码示例来源:origin: locationtech/geogig
/**
* Executes the status command using the provided options.
*/
@Override
public void runInternal(GeogigCLI cli) throws IOException {
checkParameter(limit >= 0, "Limit must be 0 or greater.");
Console console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
StatusOp op = geogig.command(StatusOp.class).setReportLimit(limit);
StatusSummary summary = op.call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
checkParameter(currHead.isPresent(), "Repository has no HEAD.");
if (currHead.get() instanceof SymRef) {
final SymRef headRef = (SymRef) currHead.get();
console.println("# On branch " + Ref.localName(headRef.getTarget()));
} else {
console.println("# Not currently on any branch.");
}
print(console, summary);
}
代码示例来源:origin: org.locationtech.geogig/geogig-cli-core
/**
* Executes the status command using the provided options.
*/
@Override
public void runInternal(GeogigCLI cli) throws IOException {
checkParameter(limit >= 0, "Limit must be 0 or greater.");
Console console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
StatusOp op = geogig.command(StatusOp.class).setReportLimit(limit);
StatusSummary summary = op.call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
checkParameter(currHead.isPresent(), "Repository has no HEAD.");
if (currHead.get() instanceof SymRef) {
final SymRef headRef = (SymRef) currHead.get();
console.println("# On branch " + Ref.localName(headRef.getTarget()));
} else {
console.println("# Not currently on any branch.");
}
print(console, summary);
}
代码示例来源:origin: org.locationtech.geogig/geogig-cli
/**
* Executes the status command using the provided options.
*/
@Override
public void runInternal(GeogigCLI cli) throws IOException {
checkParameter(limit >= 0, "Limit must be 0 or greater.");
Console console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
StatusOp op = geogig.command(StatusOp.class).setReportLimit(limit);
StatusSummary summary = op.call();
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
checkParameter(currHead.isPresent(), "Repository has no HEAD.");
if (currHead.get() instanceof SymRef) {
final SymRef headRef = (SymRef) currHead.get();
console.println("# On branch " + Ref.localName(headRef.getTarget()));
} else {
console.println("# Not currently on any branch.");
}
print(console, summary);
}
代码示例来源:origin: locationtech/geogig
public TestData checkout(String branch) {
getContext().command(CheckoutOp.class).setSource(branch).call();
Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get();
if (head instanceof SymRef) {
String target = ((SymRef) head).getTarget();
head = getContext().command(RefParse.class).setName(target).call().get();
}
String headBranch = head.localName();
checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch);
return this;
}
代码示例来源:origin: org.locationtech.geogig/geogig-core
public TestData checkout(String branch) {
getContext().command(CheckoutOp.class).setSource(branch).call();
Ref head = getContext().command(RefParse.class).setName(Ref.HEAD).call().get();
if (head instanceof SymRef) {
String target = ((SymRef) head).getTarget();
head = getContext().command(RefParse.class).setName(target).call().get();
}
String headBranch = head.localName();
checkState(branch.equals(headBranch), "expected %s, got %s", branch, headBranch);
return this;
}
代码示例来源:origin: locationtech/geogig
@Test
public void testConstructor() throws Exception {
Ref testRef = new Ref(Ref.REFS_PREFIX + "commit1", oid);
assertEquals(Ref.REFS_PREFIX + "commit1", testRef.getName());
assertEquals(Ref.REFS_PREFIX, testRef.namespace());
assertEquals("commit1", testRef.localName());
assertEquals(oid, testRef.getObjectId());
}
内容来源于网络,如有侵权,请联系作者删除!