use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitFileUtils method updateUntrackedFilesHolderOnFileRemove.
private static void updateUntrackedFilesHolderOnFileRemove(@NotNull Project project, @NotNull VirtualFile root, @NotNull Collection<VirtualFile> removedFiles) {
GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository not found for root " + root.getPresentableUrl());
return;
}
repository.getUntrackedFilesHolder().add(removedFiles);
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GithubCreatePullRequestAction method update.
public void update(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE);
if (project == null || project.isDefault()) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
final GitRepository gitRepository = GithubUtil.getGitRepository(project, file);
if (gitRepository == null) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
if (!GithubUtil.isRepositoryOnGitHub(gitRepository)) {
e.getPresentation().setEnabledAndVisible(false);
return;
}
e.getPresentation().setEnabledAndVisible(true);
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitNewBranchNameValidator method conflictsWithLocalOrRemote.
private boolean conflictsWithLocalOrRemote(@NotNull String inputString, boolean local, @NotNull String message) {
int conflictsWithCurrentName = 0;
for (GitRepository repository : myRepositories) {
if (inputString.equals(repository.getCurrentBranchName())) {
conflictsWithCurrentName++;
} else {
GitBranchesCollection branchesCollection = repository.getBranches();
Collection<? extends GitBranch> branches = local ? branchesCollection.getLocalBranches() : branchesCollection.getRemoteBranches();
for (GitBranch branch : branches) {
if (branch.getName().equals(inputString)) {
myErrorText = "Branch name " + inputString + message;
if (myRepositories.size() > 1 && !allReposHaveBranch(inputString, local)) {
myErrorText += " in repository " + repository.getPresentableUrl();
}
return true;
}
}
}
}
if (conflictsWithCurrentName == myRepositories.size()) {
myErrorText = "You are already on branch " + inputString;
return true;
}
return false;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitNewBranchNameValidator method allReposHaveBranch.
private boolean allReposHaveBranch(String inputString, boolean local) {
for (GitRepository repository : myRepositories) {
GitBranchesCollection branchesCollection = repository.getBranches();
Collection<? extends GitBranch> branches = local ? branchesCollection.getLocalBranches() : branchesCollection.getRemoteBranches();
if (!GitBranchUtil.convertBranchesToNames(branches).contains(inputString)) {
return false;
}
}
return true;
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GithubOpenInBrowserAction method getDataFromVirtualFile.
@Nullable
private static CommitData getDataFromVirtualFile(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
if (project == null || virtualFile == null)
return null;
GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile);
if (gitRepository == null || !GithubUtil.isRepositoryOnGitHub(gitRepository))
return null;
ChangeListManager changeListManager = ChangeListManager.getInstance(project);
if (changeListManager.isUnversioned(virtualFile))
return new CommitData(project, gitRepository);
Change change = changeListManager.getChange(virtualFile);
if (change != null && change.getType() == Change.Type.NEW)
return new CommitData(project, gitRepository);
return new CommitData(project, gitRepository, virtualFile);
}
Aggregations