本文整理了Java中org.eclipse.jgit.lib.Ref.getName
方法的一些代码示例,展示了Ref.getName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ref.getName
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Ref
类名称:Ref
方法名:getName
[英]What this ref is called within the repository.
[中]
代码示例来源:origin: gocd/gocd
Ref getBranch(String branchName) throws GitAPIException {
List<Ref> branches = getAllBranches();
for (Ref branch : branches) {
if (branch.getName().endsWith(branchName)) {
return branch;
}
}
return null;
}
代码示例来源:origin: spring-cloud/spring-cloud-config
private boolean containsBranch(Git git, String label, ListMode listMode)
throws GitAPIException {
ListBranchCommand command = git.branchList();
if (listMode != null) {
command.setListMode(listMode);
}
List<Ref> branches = command.call();
for (Ref ref : branches) {
if (ref.getName().endsWith("/" + label)) {
return true;
}
}
return false;
}
代码示例来源:origin: gocd/gocd
public Long commitCountOnMaster() throws GitAPIException, IncorrectObjectTypeException, MissingObjectException {
// not inside a doLocked/synchronized block because we don't want to block the server status service.
// we do a `git branch` because we switch branches as part of normal git operations,
// and we don't care about number of commits on those branches.
List<Ref> branches = git.branchList().call();
for (Ref branch : branches) {
if (branch.getName().equals("refs/heads/master")) {
Iterable<RevCommit> commits = git.log().add(branch.getObjectId()).call();
long count = 0;
for (RevCommit commit : commits) {
count++;
}
return count;
}
}
return Long.valueOf(-1);
}
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldBeOnMasterAndTemporaryBranchesDeletedAfterGettingMergeConfig() throws Exception {
String original = "first\nsecond\n";
String nextUpdate = "1st\nsecond\n";
String latestUpdate = "first\nsecond\nthird\n";
configRepo.checkin(goConfigRevision(original, "md5-1"));
configRepo.checkin(goConfigRevision(nextUpdate, "md5-2"));
RevCommit currentRevCommitOnMaster = configRepo.getCurrentRevCommit();
String mergedConfig = configRepo.getConfigMergedWithLatestRevision(goConfigRevision(latestUpdate, "md5-3"), "md5-1");
assertThat(mergedConfig, is("1st\nsecond\nthird\n"));
List<Ref> branches = getAllBranches();
assertThat(branches.size(), is(1));
assertThat(branches.get(0).getName().endsWith("master"), is(true));
assertThat(configRepo.getCurrentRevCommit(), is(currentRevCommitOnMaster));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldThrowExceptionWhenThereIsMergeConflict() throws Exception {
String original = "first\nsecond\n";
String nextUpdate = "1st\nsecond\n";
String latestUpdate = "2nd\nsecond\n";
configRepo.checkin(goConfigRevision(original, "md5-1"));
configRepo.checkin(goConfigRevision(nextUpdate, "md5-2"));
RevCommit currentRevCommitOnMaster = configRepo.getCurrentRevCommit();
try {
configRepo.getConfigMergedWithLatestRevision(goConfigRevision(latestUpdate, "md5-3"), "md5-1");
fail("should have bombed for merge conflict");
} catch (ConfigMergeException e) {
assertThat(e.getMessage(), is(ConfigFileHasChangedException.CONFIG_CHANGED_PLEASE_REFRESH));
}
List<Ref> branches = getAllBranches();
assertThat(branches.size(), is(1));
assertThat(branches.get(0).getName().endsWith("master"), is(true));
assertThat(configRepo.getCurrentRevCommit(), is(currentRevCommitOnMaster));
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
@Override
public int compare(Ref o1, Ref o2) {
return o1.getName().compareTo(o2.getName());
}
});
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Compare a reference to a name.
*
* @param o1
* the reference instance.
* @param o2
* the name to compare to.
* @return standard Comparator result of < 0, 0, > 0.
*/
public static int compareTo(Ref o1, String o2) {
return o1.getName().compareTo(o2);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
int kind(Ref r) {
if (r.getName().startsWith(R_TAGS))
return 0;
if (r.getName().startsWith(R_HEADS))
return 1;
if (r.getName().startsWith(R_REMOTES))
return 2;
return 3;
}
}
代码示例来源:origin: jphp-group/jphp
public static ArrayMemory valueOf(Ref ref) {
ArrayMemory memory = new ArrayMemory();
memory.refOfIndex("name").assign(ref.getName());
memory.refOfIndex("peeled").assign(ref.isPeeled());
memory.refOfIndex("symbolic").assign(ref.isSymbolic());
memory.refOfIndex("objectId").assign(valueOf(ref.getObjectId()));
memory.refOfIndex("storage").assign(valueOf(ref.getStorage()));
return memory;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Get the name of the ref this update will operate on.
*
* @return name of underlying ref.
*/
public String getName() {
return getRef().getName();
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Add a reference to push.
*
* @param ref
* the source reference. The remote name will match.
* @return {@code this}.
*/
public PushCommand add(Ref ref) {
refSpecs.add(new RefSpec(ref.getLeaf().getName()));
return this;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String longDescription(Ref tag, int depth, ObjectId tip)
throws IOException {
return String.format(
"%s-%d-g%s", tag.getName().substring(R_TAGS.length()), //$NON-NLS-1$
Integer.valueOf(depth), w.getObjectReader().abbreviate(tip)
.name());
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Does this specification's destination description match the ref?
*
* @param r
* ref whose name should be tested.
* @return true if the names match; false otherwise.
*/
public boolean matchDestination(Ref r) {
return match(r.getName(), getDestination());
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
public ReflogReader getReflogReader(String refName) throws IOException {
Ref ref = findRef(refName);
if (ref != null)
return new ReflogReaderImpl(this, ref.getName());
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String calculateOurName(Ref headRef) {
if (ourCommitName != null)
return ourCommitName;
String targetRefName = headRef.getTarget().getName();
String headName = Repository.shortenRefName(targetRefName);
return headName;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String calculateOurName(Ref headRef) {
if (ourCommitName != null)
return ourCommitName;
String targetRefName = headRef.getTarget().getName();
String headName = Repository.shortenRefName(targetRefName);
return headName;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static boolean equals(Ref r1, Ref r2) {
if (r1 == null || r2 == null) {
return false;
}
if (r1.isSymbolic()) {
return r2.isSymbolic() && r1.getTarget().getName()
.equals(r2.getTarget().getName());
}
return !r2.isSymbolic()
&& Objects.equals(r1.getObjectId(), r2.getObjectId());
}
代码示例来源:origin: centic9/jgit-cookbook
public static void main(String[] args) throws IOException {
try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
// the Ref holds an ObjectId for any type of object (tree, commit, blob, tree)
Ref head = repository.exactRef("refs/heads/master");
System.out.println("Ref of refs/heads/master: " + head + ": " + head.getName() + " - " + head.getObjectId().getName());
}
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/** {@inheritDoc} */
@Override
protected Result doDelete(Result desiredResult) throws IOException {
if (getRefDatabase().compareAndRemove(dstRef)) {
getRefDatabase().removed(dstRef.getName());
return desiredResult;
}
return Result.LOCK_FAILURE;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private static String getHeadName(Ref head) {
String headName;
if (head.isSymbolic()) {
headName = head.getTarget().getName();
} else {
ObjectId headId = head.getObjectId();
// the callers are checking this already
assert headId != null;
headName = headId.getName();
}
return headName;
}
内容来源于网络,如有侵权,请联系作者删除!