本文整理汇总了Java中git4idea.branch.GitBranchUtil.stripRefsPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java GitBranchUtil.stripRefsPrefix方法的具体用法?Java GitBranchUtil.stripRefsPrefix怎么用?Java GitBranchUtil.stripRefsPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git4idea.branch.GitBranchUtil
的用法示例。
在下文中一共展示了GitBranchUtil.stripRefsPrefix方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formTagDescription
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@Nullable
private static String formTagDescription(@NotNull List<String> pushedTags, @NotNull String remoteName) {
if (pushedTags.isEmpty()) {
return null;
}
if (pushedTags.size() == 1) {
return "tag " + GitBranchUtil.stripRefsPrefix(pushedTags.get(0)) + " to " + remoteName;
}
return pushedTags.size() + " tags to " + remoteName;
}
示例2: getTarget
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@Nullable
private static String getTarget(@NotNull String spec, @NotNull String sourceBranch) {
String[] parts = spec.split(":");
if (parts.length != 2) {
return null;
}
String source = parts[0].trim();
String target = parts[1].trim();
if (source.startsWith("+")) {
source = source.substring(1);
}
if (!isStarPositionValid(source, target)) {
return null;
}
source = GitBranchUtil.stripRefsPrefix(source);
sourceBranch = GitBranchUtil.stripRefsPrefix(sourceBranch);
if (source.equals(HEAD) || source.equals(sourceBranch)) return target;
if (source.endsWith("*")) {
String sourceWoStar = source.substring(0, source.length() - 1);
if (sourceBranch.startsWith(sourceWoStar)) {
String starMeaning = sourceBranch.substring(sourceWoStar.length());
return target.replace("*", starMeaning);
}
}
return null;
}
示例3: findRemoteBranch
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@Nullable
public static GitRemoteBranch findRemoteBranch(@NotNull String remoteBranchName, @NotNull final String remoteName,
@NotNull final Collection<GitRemoteBranch> remoteBranches) {
final String branchName = GitBranchUtil.stripRefsPrefix(remoteBranchName);
return ContainerUtil.find(remoteBranches, new Condition<GitRemoteBranch>() {
@Override
public boolean value(GitRemoteBranch branch) {
return branch.getNameForRemoteOperations().equals(branchName) && branch.getRemote().getName().equals(remoteName);
}
});
}
示例4: parseRemoteBranch
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
@Nullable
private static GitRemoteBranch parseRemoteBranch(@NotNull String fullBranchName,
@NotNull Hash hash,
@NotNull Collection<GitRemote> remotes) {
String stdName = GitBranchUtil.stripRefsPrefix(fullBranchName);
int slash = stdName.indexOf('/');
if (slash == -1) { // .git/refs/remotes/my_branch => git-svn
return new GitSvnRemoteBranch(fullBranchName, hash);
}
else {
GitRemote remote;
String remoteName;
String branchName;
do {
remoteName = stdName.substring(0, slash);
branchName = stdName.substring(slash + 1);
remote = GitUtil.findRemoteByName(remotes, remoteName);
slash = stdName.indexOf('/', slash + 1);
} while(remote == null && slash >= 0);
if (remote == null) {
// user may remove the remote section from .git/config, but leave remote refs untouched in .git/refs/remotes
LOG.debug(String.format("No remote found with the name [%s]. All remotes: %s", remoteName, remotes));
GitRemote fakeRemote = new GitRemote(remoteName, ContainerUtil.<String>emptyList(), Collections.<String>emptyList(),
Collections.<String>emptyList(), Collections.<String>emptyList());
return new GitStandardRemoteBranch(fakeRemote, branchName, hash);
}
return new GitStandardRemoteBranch(remote, branchName, hash);
}
}
示例5: updateTrackedBranch
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
/**
* Update tracked branch basing on the currently selected branch
*/
private void updateTrackedBranch() {
try {
final VirtualFile root = gitRoot();
String currentBranch = (String)myBranchComboBox.getSelectedItem();
GitBranch trackedBranch = null;
if (currentBranch != null) {
String remote = GitConfigUtil.getValue(myProject, root, "branch." + currentBranch + ".remote");
String mergeBranch = GitConfigUtil.getValue(myProject, root, "branch." + currentBranch + ".merge");
if (remote == null || mergeBranch == null) {
trackedBranch = null;
}
else {
mergeBranch = GitBranchUtil.stripRefsPrefix(mergeBranch);
if (remote.equals(".")) {
trackedBranch = new GitSvnRemoteBranch(mergeBranch, GitBranch.DUMMY_HASH);
}
else {
GitRemote r = GitBranchUtil.findRemoteByNameOrLogError(myProject, root, remote);
if (r != null) {
trackedBranch = new GitStandardRemoteBranch(r, mergeBranch, GitBranch.DUMMY_HASH);
}
}
}
}
if (trackedBranch != null) {
myOntoComboBox.setSelectedItem(trackedBranch);
}
else {
GitUIUtil.getTextField(myOntoComboBox).setText("");
}
GitUIUtil.getTextField(myFromComboBox).setText("");
}
catch (VcsException e) {
GitUIUtil.showOperationError(myProject, e, "git config");
}
}
示例6: assertUpstream
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
private static void assertUpstream(final String localBranch,
String expectedUpstreamRemote,
String expectedUpstreamBranch) {
String upstreamRemote = GitBranchUtil.stripRefsPrefix(git("config branch." + localBranch + ".remote"));
String upstreamBranch = GitBranchUtil.stripRefsPrefix(git("config branch." + localBranch + ".merge"));
assertEquals(expectedUpstreamRemote, upstreamRemote);
assertEquals(expectedUpstreamBranch, upstreamBranch);
}
示例7: formRepoDescription
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
private static String formRepoDescription(@NotNull GitPushRepoResult result) {
String description;
String sourceBranch = GitBranchUtil.stripRefsPrefix(result.getSourceBranch());
String targetBranch = GitBranchUtil.stripRefsPrefix(result.getTargetBranch());
String tagDescription = formTagDescription(result.getPushedTags(), result.getTargetRemote());
switch (result.getType()) {
case SUCCESS:
int commitNum = result.getNumberOfPushedCommits();
String commits = StringUtil.pluralize("commit", commitNum);
description = String.format("pushed %d %s to %s", commitNum, commits, targetBranch);
if (tagDescription != null) {
description += ", and " + tagDescription;
}
break;
case NEW_BRANCH:
description = String.format("pushed %s to new branch %s", sourceBranch, targetBranch);
if (tagDescription != null) {
description += ", and " + tagDescription;
}
break;
case UP_TO_DATE:
if (tagDescription != null) {
description = "pushed " + tagDescription;
}
else {
description = "everything is up-to-date";
}
break;
case FORCED:
description = String.format("force pushed %s to %s", sourceBranch, targetBranch);
break;
case REJECTED:
description = formDescriptionBasedOnUpdateResult(result.getUpdateResult(), targetBranch);
break;
case ERROR:
description = "failed with error: " + result.getError();
break;
default:
LOG.error("Unexpected push result: " + result);
description = "";
break;
}
return description;
}
示例8: GitBranch
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
protected GitBranch(@NotNull String name, @NotNull Hash hash) {
super(GitBranchUtil.stripRefsPrefix(name));
myHash = hash;
}
示例9: GitStandardRemoteBranch
import git4idea.branch.GitBranchUtil; //导入方法依赖的package包/类
public GitStandardRemoteBranch(@NotNull GitRemote remote, @NotNull String nameAtRemote, @NotNull Hash hash) {
super(formStandardName(remote, GitBranchUtil.stripRefsPrefix(nameAtRemote)), hash);
myRemote = remote;
myNameAtRemote = GitBranchUtil.stripRefsPrefix(nameAtRemote);
}