本文整理汇总了Java中git4idea.branch.GitBranchUtil类的典型用法代码示例。如果您正苦于以下问题:Java GitBranchUtil类的具体用法?Java GitBranchUtil怎么用?Java GitBranchUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitBranchUtil类属于git4idea.branch包,在下文中一共展示了GitBranchUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: extractBranchName
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
public static String extractBranchName(Project project) {
String branch = "";
ProjectLevelVcsManager instance = ProjectLevelVcsManagerImpl.getInstance(project);
if (instance.checkVcsIsActive("Git")) {
GitLocalBranch currentBranch = GitBranchUtil.getCurrentRepository(project).getCurrentBranch();
if (currentBranch != null) {
// Branch name matches Ticket Name
branch = currentBranch.getName().trim();
}
} else if (instance.checkVcsIsActive("Mercurial")) {
branch = HgUtil.getCurrentRepository(project).getCurrentBranch().trim();
}
return branch;
}
开发者ID:JanGatting,项目名称:GitCommitMessage,代码行数:17,代码来源:CommitMessage.java
示例2: getCurrentBranch
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
public static String getCurrentBranch(@NotNull final Project project) {
GitRepository repository;
GitLocalBranch localBranch;
String branchName = "";
try {
repository = GitBranchUtil.getCurrentRepository(project);
localBranch = repository.getCurrentBranch();
branchName = localBranch.getName();
} catch (Exception e) {
e.getMessage();
}
if (branchName == null) {
branchName = "";
}
return branchName;
}
开发者ID:crowdin,项目名称:android-studio-plugin,代码行数:17,代码来源:Utils.java
示例3: mergeCommit
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
public void mergeCommit(VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT);
handler.setStdoutSuppressed(false);
File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT);
File messageFile = new File(gitDir, GitRepositoryFiles.MERGE_MSG);
if (!messageFile.exists()) {
final GitBranch branch = GitBranchUtil.getCurrentBranch(myProject, root);
final String branchName = branch != null ? branch.getName() : "";
handler.addParameters("-m", "Merge branch '" + branchName + "' of " + root.getPresentableUrl() + " with conflicts.");
} else {
handler.addParameters("-F", messageFile.getAbsolutePath());
}
handler.endOptions();
handler.run();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GitMerger.java
示例4: refreshStashList
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
private void refreshStashList() {
final DefaultListModel listModel = (DefaultListModel)myStashList.getModel();
listModel.clear();
VirtualFile root = getGitRoot();
GitStashUtils.loadStashStack(myProject, root, new Consumer<StashInfo>() {
@Override
public void consume(StashInfo stashInfo) {
listModel.addElement(stashInfo);
}
});
myBranches.clear();
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(root);
if (repository != null) {
myBranches.addAll(GitBranchUtil.convertBranchesToNames(repository.getBranches().getLocalBranches()));
}
else {
LOG.error("Repository is null for root " + root);
}
myStashList.setSelectedIndex(0);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GitUnstashDialog.java
示例5: setCurrentBranchInfo
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
@Override
protected void setCurrentBranchInfo() {
String currentBranchText = "Current branch";
if (myRepositoryManager.moreThanOneRoot()) {
if (myMultiRootBranchConfig.diverged()) {
currentBranchText += " in " + DvcsUtil.getShortRepositoryName(myCurrentRepository) + ": " +
GitBranchUtil.getDisplayableBranchText(myCurrentRepository);
}
else {
currentBranchText += ": " + myMultiRootBranchConfig.getCurrentBranch();
}
}
else {
currentBranchText += ": " + GitBranchUtil.getDisplayableBranchText(myCurrentRepository);
}
myPopup.setAdText(currentBranchText, SwingConstants.CENTER);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GitBranchPopup.java
示例6: given
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
@NotNull
protected Collection<VcsRef> given(@NotNull String... refs) throws IOException {
Collection<VcsRef> result = ContainerUtil.newArrayList();
cd(myProjectRoot);
Hash hash = HashImpl.build(git("rev-parse HEAD"));
for (String refName : refs) {
if (isHead(refName)) {
result.add(ref(hash, "HEAD", GitRefManager.HEAD));
}
else if (isRemoteBranch(refName)) {
git("update-ref refs/remotes/" + refName + " " + hash.asString());
result.add(ref(hash, refName, GitRefManager.REMOTE_BRANCH));
}
else if (isTag(refName)) {
git("update-ref " + refName + " " + hash.asString());
result.add(ref(hash, GitBranchUtil.stripRefsPrefix(refName), GitRefManager.TAG));
}
else {
git("update-ref refs/heads/" + refName + " " + hash.asString());
result.add(ref(hash, refName, GitRefManager.LOCAL_BRANCH));
}
}
setUpTracking(result);
myRepo.update();
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GitRefManagerTest.java
示例7: expect
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
@NotNull
protected List<VcsRef> expect(@NotNull String... refNames) {
final Set<VcsRef> refs = GitTestUtil.readAllRefs(myProjectRoot, ServiceManager.getService(myProject, VcsLogObjectsFactory.class));
return ContainerUtil.map2List(refNames, new Function<String, VcsRef>() {
@Override
public VcsRef fun(@NotNull final String refName) {
VcsRef item = ContainerUtil.find(refs, new Condition<VcsRef>() {
@Override
public boolean value(VcsRef ref) {
return ref.getName().equals(GitBranchUtil.stripRefsPrefix(refName));
}
});
assertNotNull("Ref " + refName + " not found among " + refs, item);
return item;
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GitRefManagerTest.java
示例8: pushSpecsForCurrentOrEnteredBranches
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
private Map<GitRepository, GitPushSpec> pushSpecsForCurrentOrEnteredBranches() throws VcsException {
Map<GitRepository, GitPushSpec> defaultSpecs = new HashMap<GitRepository, GitPushSpec>();
for (GitRepository repository : myRepositories) {
GitLocalBranch currentBranch = repository.getCurrentBranch();
if (currentBranch == null) {
continue;
}
String remoteName = GitBranchUtil.getTrackedRemoteName(repository.getProject(), repository.getRoot(), currentBranch.getName());
String trackedBranchName = GitBranchUtil.getTrackedBranchName(repository.getProject(), repository.getRoot(), currentBranch.getName());
GitRemote remote = GitUtil.findRemoteByName(repository, remoteName);
GitRemoteBranch targetBranch;
if (remote != null && trackedBranchName != null) {
targetBranch = GitBranchUtil.findRemoteBranchByName(trackedBranchName, remote.getName(),
repository.getBranches().getRemoteBranches());
}
else {
Pair<GitRemote, GitRemoteBranch> remoteAndBranch = GitUtil.findMatchingRemoteBranch(repository, currentBranch);
if (remoteAndBranch == null) {
targetBranch = GitPusher.NO_TARGET_BRANCH;
} else {
targetBranch = remoteAndBranch.getSecond();
}
}
if (myRefspecPanel.turnedOn()) {
String manualBranchName = myRefspecPanel.getBranchToPush();
remote = myRefspecPanel.getSelectedRemote();
GitRemoteBranch manualBranch = GitBranchUtil.findRemoteBranchByName(manualBranchName, remote.getName(),
repository.getBranches().getRemoteBranches());
if (manualBranch == null) {
manualBranch = new GitStandardRemoteBranch(remote, manualBranchName, GitBranch.DUMMY_HASH);
}
targetBranch = manualBranch;
}
GitPushSpec pushSpec = new GitPushSpec(currentBranch, targetBranch == null ? GitPusher.NO_TARGET_BRANCH : targetBranch);
defaultSpecs.put(repository, pushSpec);
}
return defaultSpecs;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:GitPushDialog.java
示例9: readUnpackedRemoteBranches
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
/**
* @return list of branches from refs/remotes.
* @param remotes
*/
@NotNull
private Set<GitRemoteBranch> readUnpackedRemoteBranches(@NotNull final Collection<GitRemote> remotes) {
final Set<GitRemoteBranch> branches = new HashSet<GitRemoteBranch>();
if (!myRefsRemotesDir.exists()) {
return branches;
}
FileUtil.processFilesRecursively(myRefsRemotesDir, new Processor<File>() {
@Override
public boolean process(File file) {
if (!file.isDirectory()) {
final String relativePath = FileUtil.getRelativePath(myGitDir, file);
if (relativePath != null) {
String branchName = FileUtil.toSystemIndependentName(relativePath);
String hash = loadHashFromBranchFile(file);
GitRemoteBranch remoteBranch = GitBranchUtil.parseRemoteBranch(branchName, createHash(hash), remotes);
if (remoteBranch != null) {
branches.add(remoteBranch);
}
}
}
return true;
}
});
return branches;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:GitRepositoryReader.java
示例10: refreshStashList
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
/**
* Refresh stash list
*/
private void refreshStashList() {
final DefaultListModel listModel = (DefaultListModel)myStashList.getModel();
listModel.clear();
VirtualFile root = getGitRoot();
GitStashUtils.loadStashStack(myProject, root, new Consumer<StashInfo>() {
@Override
public void consume(StashInfo stashInfo) {
listModel.addElement(stashInfo);
}
});
myBranches.clear();
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(root);
if (repository != null) {
myBranches.addAll(GitBranchUtil.convertBranchesToNames(repository.getBranches().getLocalBranches()));
}
else {
LOG.error("Repository is null for root " + root);
}
myStashList.setSelectedIndex(0);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:GitUnstashDialog.java
示例11: update
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
private void update() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
Project project = getProject();
if (project == null) {
emptyTextAndTooltip();
return;
}
GitRepository repo = GitBranchUtil.getCurrentRepository(project);
if (repo == null) { // the file is not under version control => display nothing
emptyTextAndTooltip();
return;
}
int maxLength = myMaxString.length() - 1; // -1, because there are arrows indicating that it is a popup
myText = StringUtil.shortenTextWithEllipsis(GitBranchUtil.getDisplayableBranchText(repo), maxLength, 5);
myTooltip = getDisplayableBranchTooltip(repo);
myStatusBar.updateWidget(ID());
mySettings.setRecentRoot(repo.getRoot().getPath());
}
});
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:GitBranchWidget.java
示例12: setCurrentBranchInfo
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
private void setCurrentBranchInfo() {
String currentBranchText = "Current branch";
if (myRepositoryManager.moreThanOneRoot()) {
if (myMultiRootBranchConfig.diverged()) {
currentBranchText += " in " + DvcsUtil.getShortRepositoryName(myCurrentRepository) + ": " +
GitBranchUtil.getDisplayableBranchText(myCurrentRepository);
}
else {
currentBranchText += ": " + myMultiRootBranchConfig.getCurrentBranch();
}
}
else {
currentBranchText += ": " + GitBranchUtil.getDisplayableBranchText(myCurrentRepository);
}
myPopup.setAdText(currentBranchText, SwingConstants.CENTER);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GitBranchPopup.java
示例13: getCommonBranches
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
@NotNull
private Collection<String> getCommonBranches(boolean local) {
Collection<String> commonBranches = null;
for (GitRepository repository : myRepositories) {
GitBranchesCollection branchesCollection = repository.getBranches();
Collection<String> names = local
? GitBranchUtil.convertBranchesToNames(branchesCollection.getLocalBranches())
: GitBranchUtil.getBranchNamesWithoutRemoteHead(branchesCollection.getRemoteBranches());
if (commonBranches == null) {
commonBranches = names;
}
else {
commonBranches.retainAll(names);
}
}
if (commonBranches != null) {
ArrayList<String> common = new ArrayList<String>(commonBranches);
Collections.sort(common);
return common;
}
else {
return Collections.emptyList();
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:GitMultiRootBranchConfig.java
示例14: actionPerformed
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final int[] selectedRows = myJBTable.getSelectedRows();
if (selectedRows.length != 1) return;
final CommitI commitAt = myTableModel.getCommitAt(selectedRows[0]);
if (commitAt.holdsDecoration() || myTableModel.isStashed(commitAt)) return;
final GitRepository repository =
GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(commitAt.selectRepository(myRootsUnderVcs));
if (repository == null) return;
String reference = commitAt.getHash().getString();
final String name = GitBranchUtil
.getNewBranchNameFromUser(myProject, Collections.singleton(repository), "Checkout New Branch From " + reference);
if (name != null) {
GitBrancher brancher = ServiceManager.getService(myProject, GitBrancher.class);
brancher.checkoutNewBranchStartingFrom(name, reference, Collections.singletonList(repository), myRefresh);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:GitLogUI.java
示例15: 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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GitPushResultNotification.java
示例16: 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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GitPushSpecParser.java
示例17: getDefaultTarget
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
@Nullable
@Override
public GitPushTarget getDefaultTarget(@NotNull GitRepository repository) {
if (repository.isFresh()) {
return null;
}
GitLocalBranch currentBranch = repository.getCurrentBranch();
if (currentBranch == null) {
return null;
}
GitPushTarget persistedTarget = getPersistedTarget(repository, currentBranch);
if (persistedTarget != null) {
return persistedTarget;
}
GitPushTarget pushSpecTarget = GitPushTarget.getFromPushSpec(repository, currentBranch);
if (pushSpecTarget != null) {
return pushSpecTarget;
}
GitBranchTrackInfo trackInfo = GitBranchUtil.getTrackInfoForBranch(repository, currentBranch);
if (trackInfo != null) {
return new GitPushTarget(trackInfo.getRemoteBranch(), false);
}
return proposeTargetForNewBranch(repository, currentBranch);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:GitPushSupport.java
示例18: GitBranchesSearcher
import git4idea.branch.GitBranchUtil; //导入依赖的package包/类
public GitBranchesSearcher(final Project project, final VirtualFile root, final boolean findRemote) throws VcsException {
LOG.debug("constructing, root: " + root.getPath() + " findRemote = " + findRemote);
final Set<GitBranch> usedBranches = new HashSet<GitBranch>();
myLocal = GitBranchUtil.getCurrentBranch(project, root);
LOG.debug("local: " + myLocal);
if (myLocal == null) return;
usedBranches.add(myLocal);
GitBranch remote = myLocal;
while (true) {
remote = GitBranchUtil.tracked(project, root, remote.getName());
if (remote == null) {
LOG.debug("remote == null, exiting");
return;
}
if ((! findRemote) || remote.isRemote()) {
LOG.debug("remote found, isRemote: " + remote.isRemote() + " remoteName: " + remote.getFullName());
myRemote = remote;
return;
}
if (usedBranches.contains(remote)) {
LOG.debug("loop found for: " + remote.getFullName() + ", exiting");
return;
}
usedBranches.add(remote);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GitBranchesSearcher.java
示例19: 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);
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GitConfig.java
示例20: 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);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:GitRepositoryReader.java
注:本文中的git4idea.branch.GitBranchUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论