use of git4idea.repo.GitRepositoryManager in project intellij-community by JetBrains.
the class GithubRebaseAction method doRebaseCurrentBranch.
private static void doRebaseCurrentBranch(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final ProgressIndicator indicator) {
final GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(project);
Git git = ServiceManager.getService(Git.class);
final GitRebaser rebaser = new GitRebaser(project, git, indicator);
final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.REBASE);
handler.setStdoutSuppressed(false);
handler.addParameters("upstream/master");
final GitRebaseProblemDetector rebaseConflictDetector = new GitRebaseProblemDetector();
handler.addLineListener(rebaseConflictDetector);
final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(root);
final GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(root, CHECKOUT);
handler.addLineListener(untrackedFilesDetector);
handler.addLineListener(localChangesDetector);
handler.addLineListener(GitStandardProgressAnalyzer.createListener(indicator));
String oldText = indicator.getText();
indicator.setText("Rebasing from upstream/master...");
GitCommandResult rebaseResult = git.runCommand(handler);
indicator.setText(oldText);
repositoryManager.updateRepository(root);
if (rebaseResult.success()) {
root.refresh(false, true);
GithubNotifications.showInfo(project, "Success", "Successfully rebased GitHub fork");
} else {
GitUpdateResult result = rebaser.handleRebaseFailure(handler, root, rebaseConflictDetector, untrackedFilesDetector, localChangesDetector);
if (result == GitUpdateResult.NOTHING_TO_UPDATE || result == GitUpdateResult.SUCCESS || result == GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS) {
GithubNotifications.showInfo(project, "Success", "Successfully rebased GitHub fork");
}
}
}
use of git4idea.repo.GitRepositoryManager in project intellij-community by JetBrains.
the class GitHistoryProvider method canShowHistoryFor.
@Override
public boolean canShowHistoryFor(@NotNull VirtualFile file) {
GitRepositoryManager manager = GitUtil.getRepositoryManager(myProject);
GitRepository repository = manager.getRepositoryForFileQuick(file);
return repository != null && !repository.isFresh();
}
use of git4idea.repo.GitRepositoryManager in project intellij-community by JetBrains.
the class GitOptionsTopHitProvider method getOptions.
@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
if (project != null) {
for (VcsDescriptor descriptor : ProjectLevelVcsManager.getInstance(project).getAllVcss()) {
if ("Git".equals(descriptor.getDisplayName())) {
final GitVcsSettings settings = GitVcsSettings.getInstance(project);
ArrayList<BooleanOptionDescription> options = new ArrayList<>();
options.add(option(project, "Git: Commit automatically on cherry-pick", "isAutoCommitOnCherryPick", "setAutoCommitOnCherryPick"));
options.add(option(project, "Git: Auto-update if push of the current branch was rejected", "autoUpdateIfPushRejected", "setAutoUpdateIfPushRejected"));
GitRepositoryManager manager = GitRepositoryManager.getInstance(project);
if (manager != null && manager.moreThanOneRoot()) {
options.add(new BooleanOptionDescription("Git: Control repositories synchronously", "vcs.Git") {
@Override
public boolean isOptionEnabled() {
return settings.getSyncSetting() == DvcsSyncSettings.Value.SYNC;
}
@Override
public void setOptionState(boolean enabled) {
settings.setSyncSetting(enabled ? DvcsSyncSettings.Value.SYNC : DvcsSyncSettings.Value.DONT_SYNC);
}
});
}
options.add(option(project, "Git: Warn if CRLF line separators are about to be committed", "warnAboutCrlf", "setWarnAboutCrlf"));
options.add(option(project, "Git: Warn when committing in detached HEAD or during rebase", "warnAboutDetachedHead", "setWarnAboutDetachedHead"));
options.add(option(project, "Git: Allow force push", "isForcePushAllowed", "setForcePushAllowed"));
return Collections.unmodifiableCollection(options);
}
}
}
return Collections.emptyList();
}
Aggregations