use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchWorker method createNewTag.
public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List<GitRepository> repositories) {
for (GitRepository repository : repositories) {
myGit.createNewTag(repository, name, null, reference);
repository.getRepositoryFiles().refresh(false);
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitBranchWorker method checkoutNewBranch.
public void checkoutNewBranch(@NotNull final String name, @NotNull List<GitRepository> repositories) {
updateInfo(repositories);
repositories = ContainerUtil.filter(repositories, new Condition<GitRepository>() {
@Override
public boolean value(GitRepository repository) {
GitLocalBranch currentBranch = repository.getCurrentBranch();
return currentBranch == null || !currentBranch.getName().equals(name);
}
});
if (!repositories.isEmpty()) {
new GitCheckoutNewBranchOperation(myProject, myGit, myUiHandler, repositories, name).execute();
} else {
LOG.error("Creating new branch the same as current in all repositories: " + name);
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCheckoutOperation method smartCheckoutOrNotify.
private boolean smartCheckoutOrNotify(@NotNull GitRepository repository, @NotNull GitMessageWithFilesDetector localChangesOverwrittenByCheckout) {
Pair<List<GitRepository>, List<Change>> conflictingRepositoriesAndAffectedChanges = getConflictingRepositoriesAndAffectedChanges(repository, localChangesOverwrittenByCheckout, myCurrentHeads.get(repository), myStartPointReference);
List<GitRepository> allConflictingRepositories = conflictingRepositoriesAndAffectedChanges.getFirst();
List<Change> affectedChanges = conflictingRepositoriesAndAffectedChanges.getSecond();
Collection<String> absolutePaths = GitUtil.toAbsolute(repository.getRoot(), localChangesOverwrittenByCheckout.getRelativeFilePaths());
int smartCheckoutDecision = myUiHandler.showSmartOperationDialog(myProject, affectedChanges, absolutePaths, "checkout", "&Force Checkout");
if (smartCheckoutDecision == GitSmartOperationDialog.SMART_EXIT_CODE) {
boolean smartCheckedOutSuccessfully = smartCheckout(allConflictingRepositories, myStartPointReference, myNewBranch, getIndicator());
if (smartCheckedOutSuccessfully) {
for (GitRepository conflictingRepository : allConflictingRepositories) {
markSuccessful(conflictingRepository);
refresh(conflictingRepository);
}
return true;
} else {
// notification is handled in smartCheckout()
return false;
}
} else if (smartCheckoutDecision == GitSmartOperationDialog.FORCE_EXIT_CODE) {
boolean forceCheckoutSucceeded = checkoutOrNotify(allConflictingRepositories, myStartPointReference, myNewBranch, true);
if (forceCheckoutSucceeded) {
markSuccessful(ArrayUtil.toObjectArray(allConflictingRepositories, GitRepository.class));
refresh(ArrayUtil.toObjectArray(allConflictingRepositories, GitRepository.class));
}
return forceCheckoutSucceeded;
} else {
fatalLocalChangesError(myStartPointReference);
return false;
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCheckoutOperation method execute.
@Override
protected void execute() {
saveAllDocuments();
boolean fatalErrorHappened = false;
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
try {
while (hasMoreRepositories() && !fatalErrorHappened) {
final GitRepository repository = next();
VirtualFile root = repository.getRoot();
GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(root, GitLocalChangesWouldBeOverwrittenDetector.Operation.CHECKOUT);
GitSimpleEventDetector unmergedFiles = new GitSimpleEventDetector(GitSimpleEventDetector.Event.UNMERGED_PREVENTING_CHECKOUT);
GitSimpleEventDetector unknownPathspec = new GitSimpleEventDetector(GitSimpleEventDetector.Event.INVALID_REFERENCE);
GitUntrackedFilesOverwrittenByOperationDetector untrackedOverwrittenByCheckout = new GitUntrackedFilesOverwrittenByOperationDetector(root);
GitCommandResult result = myGit.checkout(repository, myStartPointReference, myNewBranch, false, myDetach, localChangesDetector, unmergedFiles, unknownPathspec, untrackedOverwrittenByCheckout);
if (result.success()) {
refresh(repository);
markSuccessful(repository);
} else if (unmergedFiles.hasHappened()) {
fatalUnmergedFilesError();
fatalErrorHappened = true;
} else if (localChangesDetector.wasMessageDetected()) {
boolean smartCheckoutSucceeded = smartCheckoutOrNotify(repository, localChangesDetector);
if (!smartCheckoutSucceeded) {
fatalErrorHappened = true;
}
} else if (untrackedOverwrittenByCheckout.wasMessageDetected()) {
fatalUntrackedFilesError(repository.getRoot(), untrackedOverwrittenByCheckout.getRelativeFilePaths());
fatalErrorHappened = true;
} else if (!myRefShouldBeValid && unknownPathspec.hasHappened()) {
markSkip(repository);
} else {
fatalError(getCommonErrorTitle(), result.getErrorOutputAsJoinedString());
fatalErrorHappened = true;
}
}
} finally {
token.finish();
}
if (!fatalErrorHappened) {
if (wereSuccessful()) {
if (!wereSkipped()) {
notifySuccess();
updateRecentBranch();
} else {
String mentionSuccess = getSuccessMessage() + GitUtil.mention(getSuccessfulRepositories(), 4);
String mentionSkipped = wereSkipped() ? "<br>Revision not found" + GitUtil.mention(getSkippedRepositories(), 4) : "";
VcsNotifier.getInstance(myProject).notifySuccess("", mentionSuccess + mentionSkipped + "<br><a href='rollback'>Rollback</a>", new RollbackOperationNotificationListener());
updateRecentBranch();
}
} else {
LOG.assertTrue(!myRefShouldBeValid);
notifyError("Couldn't checkout " + myStartPointReference, "Revision not found" + GitUtil.mention(getSkippedRepositories(), 4));
}
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitAbstractRebaseAction method actionPerformed.
@Override
public final void actionPerformed(AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
ProgressManager progressManager = ProgressManager.getInstance();
String progressTitle = getProgressTitle();
if (getRepositoryManager(project).hasOngoingRebase()) {
progressManager.run(new Task.Backgroundable(project, progressTitle) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
performActionForProject(project, indicator);
}
});
} else {
final GitRepository repositoryToOperate = chooseRepository(project, GitRebaseUtils.getRebasingRepositories(project));
if (repositoryToOperate != null) {
progressManager.run(new Task.Backgroundable(project, progressTitle) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
performActionForRepository(project, repositoryToOperate, indicator);
}
});
}
}
}
Aggregations