use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class GitPullDialog method setupGetBranches.
private void setupGetBranches() {
myGetBranchesButton.setIcon(AllIcons.Actions.Refresh);
myGetBranchesButton.setEnabled(myRemote.getItemCount() >= 1);
myGetBranchesButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
GitRemote selectedItem = (GitRemote) myRemote.getSelectedItem();
Collection<String> remoteBranches = selectedItem != null ? getRemoteBranches(selectedItem) : null;
if (remoteBranches != null) {
myBranchChooser.removeAllElements();
for (String branch : remoteBranches) {
myBranchChooser.addElement(branch, false);
}
}
}
});
}
use of git4idea.repo.GitRemote in project intellij-community by JetBrains.
the class GithubCreatePullRequestWorker method create.
@Nullable
public static GithubCreatePullRequestWorker create(@NotNull final Project project, @Nullable final VirtualFile file) {
return GithubUtil.computeValueInModal(project, "Loading data...", indicator -> {
Git git = ServiceManager.getService(Git.class);
GitRepository gitRepository = GithubUtil.getGitRepository(project, file);
if (gitRepository == null) {
GithubNotifications.showError(project, CANNOT_CREATE_PULL_REQUEST, "Can't find git repository");
return null;
}
gitRepository.update();
Pair<GitRemote, String> remote = GithubUtil.findGithubRemote(gitRepository);
if (remote == null) {
GithubNotifications.showError(project, CANNOT_CREATE_PULL_REQUEST, "Can't find GitHub remote");
return null;
}
String remoteName = remote.getFirst().getName();
String remoteUrl = remote.getSecond();
GithubFullPath path = GithubUrlUtil.getUserAndRepositoryFromRemoteUrl(remoteUrl);
if (path == null) {
GithubNotifications.showError(project, CANNOT_CREATE_PULL_REQUEST, "Can't process remote: " + remoteUrl);
return null;
}
GitLocalBranch currentBranch = gitRepository.getCurrentBranch();
if (currentBranch == null) {
GithubNotifications.showError(project, CANNOT_CREATE_PULL_REQUEST, "No current branch");
return null;
}
GithubAuthDataHolder authHolder;
try {
authHolder = GithubUtil.getValidAuthDataHolderFromConfig(project, AuthLevel.LOGGED, indicator);
} catch (IOException e) {
GithubNotifications.showError(project, CANNOT_CREATE_PULL_REQUEST, e);
return null;
}
GithubCreatePullRequestWorker worker = new GithubCreatePullRequestWorker(project, git, gitRepository, authHolder, path, remoteName, remoteUrl, currentBranch.getName());
try {
worker.initForks(indicator);
} catch (IOException e) {
GithubNotifications.showError(project, CANNOT_CREATE_PULL_REQUEST, e);
return null;
}
return worker;
});
}
Aggregations