Search in sources :

Example 71 with GitRepository

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GitRepository(git4idea.repo.GitRepository)

Example 72 with GitRepository

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);
}
Also used : GitRepository(git4idea.repo.GitRepository)

Example 73 with GitRepository

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();
    }
}
Also used : GitRepository(git4idea.repo.GitRepository) AccessToken(com.intellij.openapi.application.AccessToken) List(java.util.List) Map(java.util.Map)

Example 74 with GitRepository

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();
}
Also used : GitRepository(git4idea.repo.GitRepository) Map(java.util.Map) HashMap(java.util.HashMap) NotNull(org.jetbrains.annotations.NotNull)

Example 75 with GitRepository

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();
        }
    }
}
Also used : GitRepository(git4idea.repo.GitRepository) VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Aggregations

GitRepository (git4idea.repo.GitRepository)123 VirtualFile (com.intellij.openapi.vfs.VirtualFile)46 NotNull (org.jetbrains.annotations.NotNull)33 Nullable (org.jetbrains.annotations.Nullable)19 Project (com.intellij.openapi.project.Project)18 GitCommandResult (git4idea.commands.GitCommandResult)14 GitRepositoryManager (git4idea.repo.GitRepositoryManager)12 VcsException (com.intellij.openapi.vcs.VcsException)11 AccessToken (com.intellij.openapi.application.AccessToken)9 File (java.io.File)8 Map (java.util.Map)8 GitRemote (git4idea.repo.GitRemote)7 FilePath (com.intellij.openapi.vcs.FilePath)6 Change (com.intellij.openapi.vcs.changes.Change)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 Task (com.intellij.openapi.progress.Task)5 ArrayList (java.util.ArrayList)5 ObjectUtils.assertNotNull (com.intellij.util.ObjectUtils.assertNotNull)4 MultiMap (com.intellij.util.containers.MultiMap)4 GitBranch (git4idea.GitBranch)4