本文整理了Java中org.eclipse.jgit.lib.Repository.shortenRefName
方法的一些代码示例,展示了Repository.shortenRefName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.shortenRefName
方法的具体详情如下:
包路径:org.eclipse.jgit.lib.Repository
类名称:Repository
方法名:shortenRefName
[英]Get a shortened more user friendly ref name
[中]获取一个更用户友好的缩写ref name
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String getOurCommitName() {
// If onto is different from upstream, this should say "onto", but
// RebaseCommand doesn't support a different "onto" at the moment.
String ourCommitName = "Upstream, based on " //$NON-NLS-1$
+ Repository.shortenRefName(upstreamCommitName);
return ourCommitName;
}
代码示例来源: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
/**
* Initialize a new rename operation.
*
* @param src
* operation to read and delete the source.
* @param dst
* operation to create (or overwrite) the destination.
*/
protected RefRename(RefUpdate src, RefUpdate dst) {
source = src;
destination = dst;
String cmd = ""; //$NON-NLS-1$
if (source.getName().startsWith(Constants.R_HEADS)
&& destination.getName().startsWith(Constants.R_HEADS))
cmd = "Branch: "; //$NON-NLS-1$
setRefLogMessage(cmd + "renamed " //$NON-NLS-1$
+ Repository.shortenRefName(source.getName()) + " to " //$NON-NLS-1$
+ Repository.shortenRefName(destination.getName()));
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Get the short name of the current branch that {@code HEAD} points to.
* <p>
* This is essentially the same as {@link #getFullBranch()}, except the
* leading prefix {@code refs/heads/} is removed from the reference before
* it is returned to the caller.
*
* @return name of current branch (for example {@code master}), an ObjectId
* in hex format if the current branch is detached, or {@code null}
* if the repository is corrupt and has no HEAD reference.
* @throws java.io.IOException
*/
@Nullable
public String getBranch() throws IOException {
String name = getFullBranch();
if (name != null)
return shortenRefName(name);
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private String getShortBranchName(Ref headRef) {
if (headRef.isSymbolic()) {
return Repository.shortenRefName(headRef.getTarget().getName());
}
// Detached HEAD. Every non-symbolic ref in the ref database has an
// object id, so this cannot be null.
ObjectId id = headRef.getObjectId();
if (id == null) {
throw new NullPointerException();
}
return id.getName();
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
for (Ref ref : refsToMerge) {
if (ref.getName().startsWith(Constants.R_HEADS)) {
branches.add("'" + Repository.shortenRefName(ref.getName()) //$NON-NLS-1$
+ "'"); //$NON-NLS-1$
} else if (ref.getName().startsWith(Constants.R_REMOTES)) {
remoteBranches.add("'" //$NON-NLS-1$
+ Repository.shortenRefName(ref.getName()) + "'"); //$NON-NLS-1$
} else if (ref.getName().startsWith(Constants.R_TAGS)) {
tags.add("'" + Repository.shortenRefName(ref.getName()) + "'"); //$NON-NLS-1$ //$NON-NLS-2$
} else {
ObjectId objectId = ref.getObjectId();
String targetShortName = Repository.shortenRefName(targetName);
sb.append(" into " + targetShortName); //$NON-NLS-1$
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
remoteName = parent.getConfig().getString(
ConfigConstants.CONFIG_BRANCH_SECTION,
Repository.shortenRefName(ref.getName()),
ConfigConstants.CONFIG_KEY_REMOTE);
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
/**
* Get branch that HEAD currently points to
*
* @param subRepo
* a {@link org.eclipse.jgit.lib.Repository} object.
* @return shortened branch name, null on failures
* @throws java.io.IOException
*/
protected String getHeadBranch(Repository subRepo) throws IOException {
Ref head = subRepo.exactRef(Constants.HEAD);
if (head != null && head.isSymbolic())
return Repository.shortenRefName(head.getLeaf().getName());
else
return null;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private void addMergeConfig(Repository clonedRepo, Ref head)
throws IOException {
String branchName = Repository.shortenRefName(head.getName());
clonedRepo.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION,
branchName, ConfigConstants.CONFIG_KEY_REMOTE, remote);
clonedRepo.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION,
branchName, ConfigConstants.CONFIG_KEY_MERGE, head.getName());
String autosetupRebase = clonedRepo.getConfig().getString(
ConfigConstants.CONFIG_BRANCH_SECTION, null,
ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE);
if (ConfigConstants.CONFIG_KEY_ALWAYS.equals(autosetupRebase)
|| ConfigConstants.CONFIG_KEY_REMOTE.equals(autosetupRebase))
clonedRepo.getConfig().setEnum(
ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.REBASE);
clonedRepo.getConfig().save();
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
private String getOurCommitName() {
// If onto is different from upstream, this should say "onto", but
// RebaseCommand doesn't support a different "onto" at the moment.
String ourCommitName = "Upstream, based on " //$NON-NLS-1$
+ Repository.shortenRefName(upstreamCommitName);
return ourCommitName;
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
private void autoStash() throws GitAPIException, IOException {
if (repo.getConfig().getBoolean(ConfigConstants.CONFIG_REBASE_SECTION,
ConfigConstants.CONFIG_KEY_AUTOSTASH, false)) {
String message = MessageFormat.format(
AUTOSTASH_MSG,
Repository
.shortenRefName(getHeadName(getHead())));
RevCommit stashCommit = Git.wrap(repo).stashCreate().setRef(null)
.setWorkingDirectoryMessage(
message)
.call();
if (stashCommit != null) {
FileUtils.mkdir(rebaseState.getDir());
rebaseState.createFile(AUTOSTASH, stashCommit.getName());
}
}
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
.getString(
ConfigConstants.CONFIG_BRANCH_SECTION,
Repository.shortenRefName(ref.getName()),
ConfigConstants.CONFIG_KEY_MERGE);
List<RefSpec> fetchRefSpecs = remoteConfig
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
if (ref != null && !ref.getName().startsWith(Constants.R_HEADS))
ref = null;
String toName = Repository.shortenRefName(name);
RefUpdate refUpdate = repo.updateRef(Constants.HEAD, ref == null);
refUpdate.setForceUpdate(force);
代码示例来源:origin: sheimi/SGit
/**
*
* @param ref
* @return Shortened version of full ref path, suitable for display in UI
*/
public static String getCommitDisplayName(String ref) {
if (getCommitType(ref) == COMMIT_TYPE_REMOTE) {
return (ref != null && ref.length() > Constants.R_REFS.length()) ? ref.substring(Constants.R_REFS.length()) : "";
}
return Repository.shortenRefName(ref);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
ru.setNewObjectId(commitId);
String refName = Repository.shortenRefName(getRefOrHEAD());
if (isReflogDisabled) {
ru.disableRefLog();
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
refUpdate.setRefLogMessage(
"checkout: moving from " //$NON-NLS-1$
+ Repository.shortenRefName(headName)
+ " to " + commit.getName(), false); //$NON-NLS-1$
Result res = refUpdate.forceUpdate();
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
Repository.shortenRefName(remoteBranchName), remoteUri);
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
return null;
String branch = Repository.shortenRefName(head.getTarget()
.getName());
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
throws IOException {
String shortBranchName = Repository.shortenRefName(branchName);
String fullBranchName = Constants.R_HEADS + shortBranchName;
BranchConfig branchConfig = new BranchConfig(repository.getConfig(),
内容来源于网络,如有侵权,请联系作者删除!