use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class CloudGitDeploymentRuntime method fetch.
protected void fetch() throws ServerRuntimeException {
final VirtualFile contentRoot = getRepositoryRoot();
GitRepository repository = getRepository();
final GitLineHandler fetchHandler = new GitLineHandler(getProject(), contentRoot, GitCommand.FETCH);
fetchHandler.setUrl(getApplication().getGitUrl());
fetchHandler.setSilent(false);
fetchHandler.addParameters(getRemoteName());
fetchHandler.addLineListener(createGitLineHandlerListener());
performRemoteGitTask(fetchHandler, CloudBundle.getText("fetching.application", getCloudName()));
repository.update();
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class CloudGitDeploymentRuntime method deployApplication.
private void deployApplication(CloudGitApplication application) throws ServerRuntimeException {
boolean firstDeploy = findRepository() == null;
GitRepository repository = findOrCreateRepository();
addOrResetGitRemote(application, repository);
final LocalChangeList activeChangeList = myChangeListManager.getDefaultChangeList();
if (activeChangeList != null && !firstDeploy) {
commitWithChangesDialog(activeChangeList);
} else {
add();
commit();
}
repository.update();
pushApplication(application);
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCherryPicker method cherryPick.
public void cherryPick(@NotNull List<VcsFullCommitDetails> commits) {
Map<GitRepository, List<VcsFullCommitDetails>> commitsInRoots = DvcsUtil.groupCommitsByRoots(myRepositoryManager, commits);
LOG.info("Cherry-picking commits: " + toString(commitsInRoots));
List<GitCommitWrapper> successfulCommits = ContainerUtil.newArrayList();
List<GitCommitWrapper> alreadyPicked = ContainerUtil.newArrayList();
AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
try {
for (Map.Entry<GitRepository, List<VcsFullCommitDetails>> entry : commitsInRoots.entrySet()) {
GitRepository repository = entry.getKey();
boolean result = cherryPick(repository, entry.getValue(), successfulCommits, alreadyPicked);
repository.update();
if (!result) {
return;
}
}
notifyResult(successfulCommits, alreadyPicked);
} finally {
token.finish();
}
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitCompoundResult method getErrorOutputWithReposIndication.
/**
* Constructs the HTML-formatted message from error outputs of failed repositories.
* If there is only 1 repository in the project, just returns the error without writing the repository url (to avoid confusion for people
* with only 1 root ever).
* Otherwise adds repository URL to the error that repository produced.
*/
@NotNull
public String getErrorOutputWithReposIndication() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<GitRepository, GitCommandResult> entry : resultsByRepos.entrySet()) {
GitRepository repository = entry.getKey();
GitCommandResult result = entry.getValue();
if (!result.success()) {
sb.append("<p>");
if (!GitUtil.justOneGitRepository(myProject)) {
sb.append("<code>" + repository.getPresentableUrl() + "</code>:<br/>");
}
sb.append(result.getErrorOutputAsHtmlString());
sb.append("</p>");
}
}
return sb.toString();
}
use of git4idea.repo.GitRepository in project intellij-community by JetBrains.
the class GitTagDialog method runAction.
/**
* Perform tagging according to selected options
*/
public void runAction() {
final String message = myMessageTextArea.getText();
final boolean hasMessage = message.trim().length() != 0;
final File messageFile;
if (hasMessage) {
try {
messageFile = FileUtil.createTempFile(MESSAGE_FILE_PREFIX, MESSAGE_FILE_SUFFIX);
messageFile.deleteOnExit();
Writer out = new OutputStreamWriter(new FileOutputStream(messageFile), MESSAGE_FILE_ENCODING);
try {
out.write(message);
} finally {
out.close();
}
} catch (IOException ex) {
Messages.showErrorDialog(myProject, GitBundle.message("tag.error.creating.message.file.message", ex.toString()), GitBundle.getString("tag.error.creating.message.file.title"));
return;
}
} else {
messageFile = null;
}
try {
GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.TAG);
if (hasMessage) {
h.addParameters("-a");
}
if (myForceCheckBox.isEnabled() && myForceCheckBox.isSelected()) {
h.addParameters("-f");
}
if (hasMessage) {
h.addParameters("-F", messageFile.getAbsolutePath());
}
h.addParameters(myTagNameTextField.getText());
String object = myCommitTextField.getText().trim();
if (object.length() != 0) {
h.addParameters(object);
}
GitCommandResult result = myGit.runCommand(h);
if (result.success()) {
myNotifier.notifySuccess(myTagNameTextField.getText(), "Created tag " + myTagNameTextField.getText() + " successfully.");
} else {
myNotifier.notifyError("Couldn't Create Tag", result.getErrorOutputAsHtmlString());
}
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(getGitRoot());
if (repository != null) {
repository.getRepositoryFiles().refresh(true);
} else {
LOG.error("No repository registered for root: " + getGitRoot());
}
} finally {
if (messageFile != null) {
//noinspection ResultOfMethodCallIgnored
messageFile.delete();
}
}
}
Aggregations