mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -25,8 +25,10 @@ import com.intellij.ide.projectView.impl.ProjectTreeStructure;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewPane;
|
||||
import com.intellij.ide.projectView.impl.nodes.BasePsiNode;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.NavigatableWithText;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
@@ -178,13 +180,14 @@ public class ScratchProjectViewPane extends ProjectViewPane {
|
||||
|
||||
private static class MyPsiNode extends BasePsiNode<PsiFileSystemItem> implements NavigatableWithText {
|
||||
|
||||
MyPsiNode(Project project, PsiFileSystemItem value) {
|
||||
MyPsiNode(@NotNull Project project, @NotNull PsiFileSystemItem value) {
|
||||
super(project, value, ViewSettings.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysLeaf() {
|
||||
return !getValue().isDirectory();
|
||||
PsiFileSystemItem value = getValue();
|
||||
return value != null && !value.isDirectory();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -192,21 +195,26 @@ public class ScratchProjectViewPane extends ProjectViewPane {
|
||||
protected Collection<AbstractTreeNode> getChildrenImpl() {
|
||||
if (isAlwaysLeaf()) return Collections.emptyList();
|
||||
final List<AbstractTreeNode> list = ContainerUtil.newArrayList();
|
||||
getValue().processChildren(new PsiElementProcessor<PsiFileSystemItem>() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiFileSystemItem element) {
|
||||
list.add(new MyPsiNode(getProject(), element));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
PsiFileSystemItem value = getValue();
|
||||
if (value != null) {
|
||||
value.processChildren(new PsiElementProcessor<PsiFileSystemItem>() {
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiFileSystemItem element) {
|
||||
list.add(new MyPsiNode(getProject(), element));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateImpl(PresentationData data) {
|
||||
PsiFileSystemItem value = getValue();
|
||||
data.setIcon(value.getIcon(0));
|
||||
data.setPresentableText(value.getName());
|
||||
if (value != null) {
|
||||
data.setIcon(value.getIcon(0));
|
||||
data.setPresentableText(value.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -214,5 +222,15 @@ public class ScratchProjectViewPane extends ProjectViewPane {
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(@NotNull VirtualFile file) {
|
||||
PsiFileSystemItem value = getValue();
|
||||
if (!(value instanceof PsiDirectory)) return super.contains(file);
|
||||
PsiDirectory dir = (PsiDirectory)value;
|
||||
|
||||
return VfsUtilCore.isAncestor(dir.getVirtualFile(), file, false) &&
|
||||
!FileTypeRegistry.getInstance().isFileIgnored(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,11 +80,22 @@ class GitRepositoryReader {
|
||||
@NotNull
|
||||
GitBranchState readState(@NotNull Collection<GitRemote> remotes) {
|
||||
Pair<Set<GitLocalBranch>, Set<GitRemoteBranch>> branches = readBranches(remotes);
|
||||
Set<GitLocalBranch> localBranches = branches.first;
|
||||
|
||||
HeadInfo headInfo = readHead();
|
||||
Repository.State state = readRepositoryState(headInfo);
|
||||
GitLocalBranch currentBranch = findCurrentBranch(headInfo, state, branches.first);
|
||||
String currentRevision = getCurrentRevision(headInfo, currentBranch);
|
||||
return new GitBranchState(currentRevision, currentBranch, state, branches.first, branches.second);
|
||||
|
||||
GitLocalBranch currentBranch;
|
||||
String currentRevision;
|
||||
if (localBranches.isEmpty() && headInfo.content != null) {
|
||||
currentBranch = new GitLocalBranch(headInfo.content, GitBranch.DUMMY_HASH);
|
||||
currentRevision = null;
|
||||
}
|
||||
else {
|
||||
currentBranch = findCurrentBranch(headInfo, state, localBranches);
|
||||
currentRevision = getCurrentRevision(headInfo, currentBranch);
|
||||
}
|
||||
return new GitBranchState(currentRevision, currentBranch, state, localBranches, branches.second);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -18,6 +18,7 @@ package git4idea.repo;
|
||||
import com.intellij.dvcs.repo.Repository;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import git4idea.GitLocalBranch;
|
||||
import git4idea.GitRemoteBranch;
|
||||
import git4idea.test.GitSingleRepoTest;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -39,7 +40,8 @@ import static git4idea.test.GitTestUtil.makeCommit;
|
||||
public class GitRepositoryReaderNewTest extends GitSingleRepoTest {
|
||||
|
||||
// inspired by IDEA-93806
|
||||
public void test_rebase_with_conflicts_while_being_on_detached_HEAD() {
|
||||
public void test_rebase_with_conflicts_while_being_on_detached_HEAD() throws IOException {
|
||||
makeCommit("file.txt");
|
||||
conflict(myRepo, "feature");
|
||||
commit(myRepo);
|
||||
commit(myRepo);
|
||||
@@ -52,7 +54,8 @@ public class GitRepositoryReaderNewTest extends GitSingleRepoTest {
|
||||
}
|
||||
|
||||
// inspired by IDEA-124052
|
||||
public void test_remote_reference_without_remote() {
|
||||
public void test_remote_reference_without_remote() throws IOException {
|
||||
makeCommit("file.txt");
|
||||
final String INVALID_REMOTE = "invalid-remote";
|
||||
final String INVALID_REMOTE_BRANCH = "master";
|
||||
git("update-ref refs/remotes/" + INVALID_REMOTE + "/" + INVALID_REMOTE_BRANCH + " HEAD");
|
||||
@@ -68,6 +71,7 @@ public class GitRepositoryReaderNewTest extends GitSingleRepoTest {
|
||||
|
||||
// inspired by IDEA-134286
|
||||
public void test_detached_HEAD() throws IOException {
|
||||
makeCommit("file.txt");
|
||||
makeCommit("file.txt");
|
||||
git("checkout HEAD^");
|
||||
GitBranchState state = readState();
|
||||
@@ -84,4 +88,15 @@ public class GitRepositoryReaderNewTest extends GitSingleRepoTest {
|
||||
return reader.readState(remotes);
|
||||
}
|
||||
|
||||
// inspired by IDEA-134412
|
||||
public void test_fresh_repository_is_on_branch() {
|
||||
GitLocalBranch currentBranch = readState().getCurrentBranch();
|
||||
assertNotNull("Current branch shouldn't be null in a fresh repository", currentBranch);
|
||||
assertEquals("Fresh repository should be on master", "master", currentBranch.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean makeInitialCommit() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user