Search in sources :

Example 26 with NoRepositorySelected

use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.

the class CurrentBranchRemotesDialog method doOK.

@Override
protected void doOK() {
    RemoteBranchItem currentSelectedBranch = (RemoteBranchItem) remoteBranchItems.getSelectedItem();
    if (!currentSelectedBranch.isUndefined() && !currentSelectedBranch.isFirstSelection()) {
        try {
            BranchConfigurations branchConfig = new BranchConfigurations(GitAccess.getInstance().getRepository().getConfig(), currentBranch);
            branchConfig.setRemote(currentSelectedBranch.remote);
            branchConfig.setMerge(currentSelectedBranch.branch);
            GitAccess.getInstance().updateConfigFile();
        } catch (NoRepositorySelected e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
    super.doOK();
}
Also used : NoRepositorySelected(com.oxygenxml.git.service.NoRepositorySelected) BranchConfigurations(com.oxygenxml.git.view.branches.BranchConfigurations)

Example 27 with NoRepositorySelected

use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.

the class DiffPresenter method diffViewForAddedAndUntracked.

/**
 * Diff for added/untracked resources.
 *
 * @param fileStatus File to compare.
 */
private static void diffViewForAddedAndUntracked(FileStatus fileStatus) {
    URL url = null;
    try {
        GitChangeType changeType = fileStatus.getChangeType();
        if (changeType == GitChangeType.ADD) {
            url = GitRevisionURLHandler.encodeURL(VersionIdentifier.INDEX_OR_LAST_COMMIT, fileStatus.getFileLocation());
        } else {
            url = FileUtil.getFileURL(fileStatus.getFileLocation());
        }
    } catch (MalformedURLException | NoRepositorySelected e) {
        // Shouldn't rreally happen
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(e.getMessage(), e);
        }
    }
    showDiffFrame(url, null, null, fileStatus.getFileLocation());
}
Also used : NoRepositorySelected(com.oxygenxml.git.service.NoRepositorySelected) MalformedURLException(java.net.MalformedURLException) GitChangeType(com.oxygenxml.git.service.entities.GitChangeType) URL(java.net.URL)

Example 28 with NoRepositorySelected

use of com.oxygenxml.git.service.NoRepositorySelected in project oxygen-git-client-addon by oxygenxml.

the class RepoGenerationScript method setUserCredentials.

public static void setUserCredentials() {
    try {
        StoredConfig config = GitAccess.getInstance().getRepository().getConfig();
        config.setString("user", null, "name", "AlexJitianu");
        config.setString("user", null, "email", "alex_jitianu@sync.ro");
        config.save();
    } catch (NoRepositorySelected | IOException e) {
        e.printStackTrace();
    }
}
Also used : StoredConfig(org.eclipse.jgit.lib.StoredConfig) NoRepositorySelected(com.oxygenxml.git.service.NoRepositorySelected) IOException(java.io.IOException)

Aggregations

NoRepositorySelected (com.oxygenxml.git.service.NoRepositorySelected)28 IOException (java.io.IOException)15 File (java.io.File)10 URL (java.net.URL)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 Repository (org.eclipse.jgit.lib.Repository)6 FileStatus (com.oxygenxml.git.service.entities.FileStatus)4 MalformedURLException (java.net.MalformedURLException)4 RevCommit (org.eclipse.jgit.revwalk.RevCommit)4 RepoNotInitializedException (com.oxygenxml.git.service.RepoNotInitializedException)3 ActionEvent (java.awt.event.ActionEvent)3 AbstractAction (javax.swing.AbstractAction)3 BranchInfo (com.oxygenxml.git.service.BranchInfo)2 GitChangeType (com.oxygenxml.git.service.entities.GitChangeType)2 Translator (com.oxygenxml.git.translator.Translator)2 CheckoutCommitAction (com.oxygenxml.git.view.history.actions.CheckoutCommitAction)2 CreateBranchFromCommitAction (com.oxygenxml.git.view.history.actions.CreateBranchFromCommitAction)2 CreateTagAction (com.oxygenxml.git.view.history.actions.CreateTagAction)2 ResetBranchToCommitAction (com.oxygenxml.git.view.history.actions.ResetBranchToCommitAction)2 RevertCommitAction (com.oxygenxml.git.view.history.actions.RevertCommitAction)2