use of com.oxygenxml.git.service.GitStatus in project oxygen-git-client-addon by oxygenxml.
the class ProjectMenuGitActionsProvider method getStagedAndUnstagedFiles.
/**
* @return The staged and the unstaged files.
*/
private List<FileStatus> getStagedAndUnstagedFiles() {
List<FileStatus> gitFiles = new ArrayList<>();
GitStatus status = GitAccess.getInstance().getStatus();
gitFiles.addAll(status.getUnstagedFiles());
gitFiles.addAll(status.getStagedFiles());
return gitFiles;
}
use of com.oxygenxml.git.service.GitStatus in project oxygen-git-client-addon by oxygenxml.
the class CommitAndStatusPanel method toggleCommitButtonAndUpdateMessageArea.
/**
* Checks if the commit button should be enabled.
*
* @param forceEnable <code>true</code> to make the button enable without any additional checks.
*/
void toggleCommitButtonAndUpdateMessageArea(boolean forceEnable) {
if (forceEnable) {
commitButton.setEnabled(true);
} else {
try {
Repository repo = gitAccess.getRepository();
final RepositoryState repositoryState = repo.getRepositoryState();
final String mergeMessage = MessageFormat.format(translator.getTranslation(Tags.COMMIT_TO_MERGE), gitAccess.getBranchInfo().getBranchName(), repo.getConfig().getString("remote", "origin", "url"));
// Possible time consuming operations.
commitButtonAndMessageUpdateTask = new SwingWorker<Void, Void>() {
boolean enable = false;
String message = null;
@Override
protected Void doInBackground() throws Exception {
GitStatus status = gitAccess.getStatus();
if (repositoryState == RepositoryState.MERGING_RESOLVED && status.getStagedFiles().isEmpty() && status.getUnstagedFiles().isEmpty()) {
enable = true;
message = mergeMessage;
} else if (!status.getStagedFiles().isEmpty() || amendLastCommitToggle.isSelected()) {
enable = true;
}
return null;
}
@Override
protected void done() {
if (message != null) {
commitMessageArea.setText(message);
}
commitButton.setEnabled(enable);
}
};
commitButtonAndMessageUpdateTaskTimer.restart();
} catch (NoRepositorySelected e) {
// Remains disabled
}
}
}
use of com.oxygenxml.git.service.GitStatus in project oxygen-git-client-addon by oxygenxml.
the class StagingPanel method treatPushPullFinished.
/**
* Push/pull finished. Treat the event.
*
* @param pushPullEvent The event.
*/
private void treatPushPullFinished(PushPullEvent pushPullEvent) {
SwingUtilities.invokeLater(() -> {
commitPanel.setStatusMessage(pushPullEvent.getMessage());
commitPanel.reset();
commitPanel.toggleCommitButtonAndUpdateMessageArea(false);
workingCopySelectionPanel.getBrowseButton().setEnabled(true);
workingCopySelectionPanel.getWorkingCopyCombo().setEnabled(true);
branchSelectionCombo.setEnabled(true);
});
// Update models.
final GitStatus status = GitAccess.getInstance().getStatus();
SwingUtilities.invokeLater(() -> {
unstagedChangesPanel.update(status.getUnstagedFiles());
stagedChangesPanel.update(status.getStagedFiles());
});
branchSelectionCombo.refresh();
if (toolbarPanel != null) {
toolbarPanel.updateButtonsStates();
}
gitActionsManager.refreshActionsStates();
}
use of com.oxygenxml.git.service.GitStatus in project oxygen-git-client-addon by oxygenxml.
the class RepoUtil method isNonConflictualRepoWithUncommittedChanges.
/**
* Verify if the repo is non-conflictual and has uncommitted changes.
*
* @param repoState The repo state.
*
* @return <code>true</code> if the repository is not merging, not rebasing and with uncommitted changes.
*/
public static boolean isNonConflictualRepoWithUncommittedChanges(RepositoryState repoState) {
GitStatus status = GitAccess.getInstance().getStatus();
boolean repoHasUncommittedChanges = !status.getUnstagedFiles().isEmpty() || !status.getStagedFiles().isEmpty();
return repoHasUncommittedChanges && !RepoUtil.isUnfinishedConflictState(repoState);
}
Aggregations