Merge pull request #473 from eclipse/CHE-521
CHE-521: Perform git init command without initial commit6.19.x
commit
e2d3585e50
|
|
@ -14,6 +14,7 @@ package org.eclipse.che.git.impl.nativegit;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.eclipse.che.api.core.ErrorCodes;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.UnauthorizedException;
|
||||
import org.eclipse.che.api.core.util.LineConsumerFactory;
|
||||
import org.eclipse.che.api.git.Config;
|
||||
|
|
@ -175,8 +176,15 @@ public class NativeGitConnection implements GitConnection {
|
|||
public Branch branchCreate(BranchCreateRequest request) throws GitException {
|
||||
BranchCreateCommand branchCreateCommand = nativeGit.createBranchCreateCommand();
|
||||
branchCreateCommand.setBranchName(request.getName())
|
||||
.setStartPoint(request.getStartPoint())
|
||||
.execute();
|
||||
.setStartPoint(request.getStartPoint());
|
||||
try {
|
||||
branchCreateCommand.execute();
|
||||
} catch (ServerException exception) {
|
||||
Pattern errorPattern = Pattern.compile("fatal: Not a valid object name: '.*'.\n");
|
||||
if (errorPattern.matcher(exception.getMessage()).find()) {
|
||||
throw new GitException(exception.getMessage(), ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
|
||||
}
|
||||
}
|
||||
return DtoFactory.getInstance().createDto(Branch.class).withName(getBranchRef(request.getName())).withActive(false)
|
||||
.withDisplayName(request.getName()).withRemote(false);
|
||||
}
|
||||
|
|
@ -358,25 +366,20 @@ public class NativeGitConnection implements GitConnection {
|
|||
InitCommand initCommand = nativeGit.createInitCommand();
|
||||
initCommand.setBare(request.isBare());
|
||||
initCommand.execute();
|
||||
//make initial commit.
|
||||
if (!request.isBare() && request.isInitCommit()) {
|
||||
try {
|
||||
nativeGit.createAddCommand()
|
||||
.setFilePattern(new ArrayList<>(Collections.singletonList(".")))
|
||||
.execute();
|
||||
nativeGit.createCommitCommand()
|
||||
.setCommitter(getLocalCommitter())
|
||||
.setMessage("init")
|
||||
.execute();
|
||||
} catch (GitException ignored) {
|
||||
//if nothing to commit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogPage log(LogRequest request) throws GitException {
|
||||
return new LogPage(nativeGit.createLogCommand().setFileFilter(request.getFileFilter()).execute());
|
||||
try {
|
||||
return new LogPage(nativeGit.createLogCommand().setFileFilter(request.getFileFilter()).execute());
|
||||
} catch (ServerException exception) {
|
||||
Pattern errorPattern = Pattern.compile("fatal: your current branch '.*' does not have any commits yet\n");
|
||||
if (errorPattern.matcher(exception.getMessage()).find()) {
|
||||
throw new GitException(exception.getMessage(), ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED);
|
||||
} else {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ public class BranchRenameCommand extends RemoteOperationCommand<Void> {
|
|||
commandLine.add("-t");
|
||||
commandLine.add(branchName);
|
||||
start();
|
||||
} catch (GitException e) {
|
||||
String errorMessage = e.getMessage();
|
||||
} catch (GitException exception) {
|
||||
String errorMessage = exception.getMessage();
|
||||
if (!checkoutErrorPattern.matcher(errorMessage).find()) {
|
||||
throw new GitException(errorMessage);
|
||||
throw exception;
|
||||
}
|
||||
//local branch already exist - so ignore and try perform the next step
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ importProject.message.failure = Failed to import project {0}
|
|||
importProject.message.startWithWhiteSpace = The url can not start with a whitespace.
|
||||
importProject.message.urlInvalid = The URL provided for the project to import is invalid.
|
||||
importProject.message.unableGetSshKey = Unable get private ssh key. \
|
||||
You can create a new SSH key pair in Window->Preferences->Keys->SSH Keystore.
|
||||
You can create a new SSH key pair in Help->Preferences->SSH->Git.
|
||||
importProject.importer.info = Importer Information
|
||||
importProject.project.info = Project Information
|
||||
importProject.name.prompt = Define the name of your project...
|
||||
|
|
|
|||
|
|
@ -142,7 +142,6 @@ public class GitServiceClientImpl implements GitServiceClient{
|
|||
InitRequest initRequest = dtoFactory.createDto(InitRequest.class);
|
||||
initRequest.setBare(bare);
|
||||
initRequest.setWorkingDir(project.getName());
|
||||
initRequest.setInitCommit(true);
|
||||
|
||||
String url = "/git/" + workspaceId + INIT + "?projectPath=" + project.getPath();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,4 +24,5 @@ public class ErrorCodes {
|
|||
public static final int UNAUTHORIZED_GIT_OPERATION = 32080;
|
||||
public static final int FAILED_CHECKOUT = 32063;
|
||||
public static final int FAILED_CHECKOUT_WITH_START_POINT = 32064;
|
||||
public static final int INIT_COMMIT_WAS_NOT_PERFORMED = 32082;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ public class GitProjectImporter implements ProjectImporter {
|
|||
}
|
||||
|
||||
private void initRepository(GitConnection git, DtoFactory dtoFactory) throws GitException {
|
||||
final InitRequest request = dtoFactory.createDto(InitRequest.class).withInitCommit(false).withBare(false);
|
||||
final InitRequest request = dtoFactory.createDto(InitRequest.class).withBare(false);
|
||||
git.init(request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,4 @@ public interface InitRequest extends GitRequest {
|
|||
void setBare(boolean bare);
|
||||
|
||||
InitRequest withBare(boolean bare);
|
||||
|
||||
/** @return <code>true</code> then all files in newly initialized repository will be commited with "init" message */
|
||||
boolean isInitCommit();
|
||||
|
||||
void setInitCommit(boolean initCommit);
|
||||
|
||||
InitRequest withInitCommit(boolean initCommit);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,6 @@ public interface GitLocalizationConstant extends Messages {
|
|||
String buttonScroll();
|
||||
|
||||
// MESSAGES
|
||||
@Key("messages.unableGetSshKeyTitle")
|
||||
String messagesUnableGetSshKeyTitle();
|
||||
|
||||
@Key("messages.unableGetSshKey")
|
||||
String messagesUnableGetSshKey();
|
||||
|
||||
|
|
@ -121,6 +118,9 @@ public interface GitLocalizationConstant extends Messages {
|
|||
|
||||
@Key("messages.committer_identity_info_empty")
|
||||
String committerIdentityInfoEmpty();
|
||||
|
||||
@Key("messages.init_commit_was_not_performed")
|
||||
String initCommitWasNotPerformed();
|
||||
|
||||
@Key("messages.diff.failed")
|
||||
String diffFailed();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
|
||||
import org.eclipse.che.api.core.ErrorCodes;
|
||||
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
|
||||
import org.eclipse.che.api.git.shared.Branch;
|
||||
import org.eclipse.che.api.git.shared.CheckoutRequest;
|
||||
|
|
@ -49,10 +49,12 @@ import org.eclipse.che.ide.ui.dialogs.DialogFactory;
|
|||
import org.eclipse.che.ide.ui.dialogs.InputCallback;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.eclipse.che.api.git.shared.BranchListRequest.LIST_ALL;
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode;
|
||||
|
||||
/**
|
||||
* Presenter for displaying and work with branches.
|
||||
|
|
@ -174,12 +176,7 @@ public class BranchPresenter implements BranchView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
String errorMessage =
|
||||
(exception.getMessage() != null) ? exception.getMessage() : constant.branchRenameFailed();
|
||||
final GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_RENAME_COMMAND_NAME);
|
||||
console.printError(errorMessage);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
notificationManager.notify(constant.branchRenameFailed(), FAIL, true, project.getRootProject());
|
||||
handleError(exception, BRANCH_RENAME_COMMAND_NAME);
|
||||
getBranches();//rename of remote branch occurs in three stages, so needs update list of branches on view
|
||||
}
|
||||
});
|
||||
|
|
@ -205,9 +202,7 @@ public class BranchPresenter implements BranchView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_DELETE_COMMAND_NAME);
|
||||
handleError(exception, console);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
handleError(exception, BRANCH_DELETE_COMMAND_NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -257,9 +252,7 @@ public class BranchPresenter implements BranchView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
final GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_CHECKOUT_COMMAND_NAME);
|
||||
printGitMessage(exception.getMessage(), console);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
handleError(exception, BRANCH_CHECKOUT_COMMAND_NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -302,44 +295,25 @@ public class BranchPresenter implements BranchView.ActionDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private void printGitMessage(String messageText, GitOutputConsole console) {
|
||||
if (messageText == null || messageText.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject = JSONParser.parseStrict(messageText).isObject();
|
||||
if (jsonObject == null) {
|
||||
return;
|
||||
}
|
||||
String message = "";
|
||||
if (jsonObject.containsKey("message")) {
|
||||
message = jsonObject.get("message").isString().stringValue();
|
||||
}
|
||||
|
||||
console.print("");
|
||||
String[] lines = message.split("\n");
|
||||
for (String line : lines) {
|
||||
console.printError(line);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the list of branches. */
|
||||
private void getBranches() {
|
||||
service.branchList(workspaceId, project.getRootProject(), LIST_ALL,
|
||||
new AsyncRequestCallback<List<Branch>>(dtoUnmarshallerFactory.newListUnmarshaller(Branch.class)) {
|
||||
@Override
|
||||
protected void onSuccess(List<Branch> result) {
|
||||
view.setBranches(result);
|
||||
view.showDialogIfClosed();
|
||||
if (result.isEmpty()) {
|
||||
dialogFactory.createMessageDialog(constant.branchTitle(),
|
||||
constant.initCommitWasNotPerformed(),
|
||||
null).show();
|
||||
} else {
|
||||
view.setBranches(result);
|
||||
view.showDialogIfClosed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
final String errorMessage =
|
||||
(exception.getMessage() != null) ? exception.getMessage() : constant.branchesListFailed();
|
||||
final GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_LIST_COMMAND_NAME);
|
||||
console.printError(errorMessage);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
notificationManager.notify(constant.branchesListFailed(), FAIL, true, project.getRootProject());
|
||||
handleError(exception, BRANCH_LIST_COMMAND_NAME);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -361,16 +335,10 @@ public class BranchPresenter implements BranchView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
final String errorMessage = (exception.getMessage() != null)
|
||||
? exception.getMessage()
|
||||
: constant.branchCreateFailed();
|
||||
final GitOutputConsole console = gitOutputConsoleFactory.create(BRANCH_CREATE_COMMAND_NAME);
|
||||
console.printError(errorMessage);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
notificationManager.notify(constant.branchCreateFailed(), FAIL, true, project.getRootProject());
|
||||
handleError(exception, BRANCH_CREATE_COMMAND_NAME);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -400,32 +368,50 @@ public class BranchPresenter implements BranchView.ActionDelegate {
|
|||
/**
|
||||
* Handler some action whether some exception happened.
|
||||
*
|
||||
* @param throwable
|
||||
* @param exception
|
||||
* exception what happened
|
||||
* @param console
|
||||
* console for displaying error
|
||||
* @param commandName
|
||||
* name of the executed command
|
||||
*/
|
||||
void handleError(@NotNull Throwable throwable, GitOutputConsole console) {
|
||||
String errorMessage = throwable.getMessage();
|
||||
if (errorMessage == null) {
|
||||
console.printError(constant.branchDeleteFailed());
|
||||
notificationManager.notify(constant.branchDeleteFailed(), FAIL, true, project.getRootProject());
|
||||
void handleError(@NotNull Throwable exception, String commandName) {
|
||||
if (getErrorCode(exception) == ErrorCodes.UNABLE_GET_PRIVATE_SSH_KEY) {
|
||||
dialogFactory.createMessageDialog(commandName, constant.messagesUnableGetSshKey(), null).show();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
errorMessage = dtoFactory.createDtoFromJson(errorMessage, ServiceError.class).getMessage();
|
||||
if (errorMessage.equals("Unable get private ssh key")) {
|
||||
console.printError(constant.messagesUnableGetSshKey());
|
||||
notificationManager.notify(constant.messagesUnableGetSshKeyTitle(), constant.messagesUnableGetSshKey(), FAIL, true,
|
||||
project.getRootProject());
|
||||
return;
|
||||
String errorMessage = exception.getMessage();
|
||||
if (errorMessage == null) {
|
||||
switch (commandName) {
|
||||
case BRANCH_CREATE_COMMAND_NAME:
|
||||
errorMessage = constant.branchCreateFailed();
|
||||
break;
|
||||
case BRANCH_DELETE_COMMAND_NAME:
|
||||
errorMessage = constant.branchDeleteFailed();
|
||||
break;
|
||||
case BRANCH_LIST_COMMAND_NAME:
|
||||
errorMessage = constant.branchesListFailed();
|
||||
break;
|
||||
case BRANCH_RENAME_COMMAND_NAME:
|
||||
errorMessage = constant.branchRenameFailed();
|
||||
break;
|
||||
case BRANCH_CHECKOUT_COMMAND_NAME:
|
||||
errorMessage = constant.branchCheckoutFailed();
|
||||
break;
|
||||
}
|
||||
console.printError(errorMessage);
|
||||
notificationManager.notify(errorMessage, FAIL, true, project.getRootProject());
|
||||
} catch (Exception e) {
|
||||
console.printError(errorMessage);
|
||||
notificationManager.notify(errorMessage, FAIL, true, project.getRootProject());
|
||||
}
|
||||
|
||||
GitOutputConsole console = gitOutputConsoleFactory.create(commandName);
|
||||
printGitMessage(errorMessage, console);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
notificationManager.notify(errorMessage, FAIL, true, project.getRootProject());
|
||||
}
|
||||
|
||||
private void printGitMessage(String messageText, GitOutputConsole console) {
|
||||
console.print("");
|
||||
String[] lines = messageText.split("\n");
|
||||
for (String line : lines) {
|
||||
console.printError(line);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import org.eclipse.che.api.core.ErrorCodes;
|
|||
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
|
||||
import org.eclipse.che.api.git.shared.LogResponse;
|
||||
import org.eclipse.che.api.git.shared.Revision;
|
||||
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
|
||||
import org.eclipse.che.ide.api.app.AppContext;
|
||||
import org.eclipse.che.ide.api.notification.NotificationManager;
|
||||
import org.eclipse.che.ide.api.project.node.HasStorablePath;
|
||||
|
|
@ -43,6 +44,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode;
|
||||
|
||||
/**
|
||||
* Presenter for commit changes on git.
|
||||
|
|
@ -275,8 +277,9 @@ public class CommitPresenter implements CommitView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
public void setAmendCommitMessage() {
|
||||
final ProjectConfigDto project = appContext.getCurrentProject().getRootProject();
|
||||
final Unmarshallable<LogResponse> unmarshall = dtoUnmarshallerFactory.newUnmarshaller(LogResponse.class);
|
||||
this.service.log(workspaceId, appContext.getCurrentProject().getRootProject(), null, false,
|
||||
this.service.log(workspaceId, project, null, false,
|
||||
new AsyncRequestCallback<LogResponse>(unmarshall) {
|
||||
@Override
|
||||
protected void onSuccess(final LogResponse result) {
|
||||
|
|
@ -294,8 +297,15 @@ public class CommitPresenter implements CommitView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
protected void onFailure(final Throwable exception) {
|
||||
Log.warn(CommitPresenter.class, "Git log failed", exception);
|
||||
CommitPresenter.this.view.setMessage("");
|
||||
if (getErrorCode(exception) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
|
||||
dialogFactory.createMessageDialog(constant.commitTitle(),
|
||||
constant.initCommitWasNotPerformed(),
|
||||
null).show();
|
||||
} else {
|
||||
Log.warn(CommitPresenter.class, "Git log failed", exception);
|
||||
CommitPresenter.this.view.setMessage("");
|
||||
notificationManager.notify(constant.logFailed(), FAIL, false, project);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ package org.eclipse.che.ide.ext.git.client.compare.revisionsList;
|
|||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.core.ErrorCodes;
|
||||
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
|
||||
import org.eclipse.che.api.git.shared.LogResponse;
|
||||
import org.eclipse.che.api.git.shared.Revision;
|
||||
|
|
@ -36,6 +37,7 @@ import java.util.Collections;
|
|||
|
||||
import static org.eclipse.che.api.git.shared.DiffRequest.DiffType.NAME_STATUS;
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode;
|
||||
|
||||
/**
|
||||
* Presenter for displaying list of revisions for comparing selected with local changes.
|
||||
|
|
@ -149,7 +151,14 @@ public class RevisionListPresenter implements RevisionListView.ActionDelegate {
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
notificationManager.notify(locale.logFailed(), FAIL, false);
|
||||
if (getErrorCode(exception) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
|
||||
dialogFactory.createMessageDialog(locale.compareWithRevisionTitle(),
|
||||
locale.initCommitWasNotPerformed(),
|
||||
null).show();
|
||||
} else {
|
||||
notificationManager.notify(locale.logFailed(), FAIL, false);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.ErrorCodes;
|
||||
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
|
||||
import org.eclipse.che.api.git.shared.LogResponse;
|
||||
import org.eclipse.che.api.git.shared.Revision;
|
||||
|
|
@ -42,15 +43,18 @@ import org.eclipse.che.ide.extension.machine.client.processes.ConsolesPanelPrese
|
|||
import org.eclipse.che.ide.rest.AsyncRequestCallback;
|
||||
import org.eclipse.che.ide.rest.DtoUnmarshallerFactory;
|
||||
import org.eclipse.che.ide.rest.StringUnmarshaller;
|
||||
import org.eclipse.che.ide.ui.dialogs.DialogFactory;
|
||||
import org.vectomatic.dom.svg.ui.SVGResource;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.eclipse.che.api.git.shared.DiffRequest.DiffType.RAW;
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode;
|
||||
|
||||
/**
|
||||
* Presenter for showing git history.
|
||||
|
|
@ -71,6 +75,7 @@ public class HistoryPresenter extends BasePresenter implements HistoryView.Actio
|
|||
private final GitLocalizationConstant constant;
|
||||
private final GitResources resources;
|
||||
private final AppContext appContext;
|
||||
private final DialogFactory dialogFactory;
|
||||
private final WorkspaceAgent workspaceAgent;
|
||||
private final DateTimeFormatter dateTimeFormatter;
|
||||
private final GitOutputConsoleFactory gitOutputConsoleFactory;
|
||||
|
|
@ -94,12 +99,14 @@ public class HistoryPresenter extends BasePresenter implements HistoryView.Actio
|
|||
GitLocalizationConstant constant,
|
||||
AppContext appContext,
|
||||
NotificationManager notificationManager,
|
||||
DialogFactory dialogFactory,
|
||||
DtoUnmarshallerFactory dtoUnmarshallerFactory,
|
||||
DateTimeFormatter dateTimeFormatter,
|
||||
SelectionAgent selectionAgent,
|
||||
GitOutputConsoleFactory gitOutputConsoleFactory,
|
||||
ConsolesPanelPresenter consolesPanelPresenter) {
|
||||
this.view = view;
|
||||
this.dialogFactory = dialogFactory;
|
||||
this.dateTimeFormatter = dateTimeFormatter;
|
||||
this.gitOutputConsoleFactory = gitOutputConsoleFactory;
|
||||
this.consolesPanelPresenter = consolesPanelPresenter;
|
||||
|
|
@ -155,7 +162,7 @@ public class HistoryPresenter extends BasePresenter implements HistoryView.Actio
|
|||
|
||||
/** Get the log of the commits. If successfully received, then display in revision grid, otherwise - show error in output panel. */
|
||||
private void getCommitsLog(final ProjectConfigDto project) {
|
||||
service.log(workspaceId, project, null, false,
|
||||
service.log(workspaceId, project, null, false,
|
||||
new AsyncRequestCallback<LogResponse>(dtoUnmarshallerFactory.newUnmarshaller(LogResponse.class)) {
|
||||
@Override
|
||||
protected void onSuccess(LogResponse result) {
|
||||
|
|
@ -165,12 +172,21 @@ public class HistoryPresenter extends BasePresenter implements HistoryView.Actio
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
nothingToDisplay(null);
|
||||
String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.logFailed();
|
||||
GitOutputConsole console = gitOutputConsoleFactory.create(LOG_COMMAND_NAME);
|
||||
console.printError(errorMessage);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
notificationManager.notify(constant.logFailed(), FAIL, true, project);
|
||||
if (getErrorCode(exception) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
|
||||
dialogFactory.createMessageDialog(constant.historyTitle(),
|
||||
constant.initCommitWasNotPerformed(),
|
||||
null).show();
|
||||
} else {
|
||||
nothingToDisplay(null);
|
||||
String errorMessage = exception.getMessage() != null ? exception.getMessage() : constant.logFailed();
|
||||
GitOutputConsole console = gitOutputConsoleFactory.create(LOG_COMMAND_NAME);
|
||||
console.printError(errorMessage);
|
||||
consolesPanelPresenter.addCommandOutput(appContext.getDevMachineId(), console);
|
||||
notificationManager.notify(constant.logFailed(), FAIL, true, project);
|
||||
}
|
||||
partStack.hidePart(HistoryPresenter.this);
|
||||
workspaceAgent.removePart(HistoryPresenter.this);
|
||||
isViewClosed = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
import org.eclipse.che.api.core.ErrorCodes;
|
||||
import org.eclipse.che.api.git.gwt.client.GitServiceClient;
|
||||
import org.eclipse.che.api.git.shared.LogResponse;
|
||||
import org.eclipse.che.api.git.shared.ResetRequest;
|
||||
|
|
@ -30,13 +31,16 @@ import org.eclipse.che.ide.ext.git.client.outputconsole.GitOutputConsoleFactory;
|
|||
import org.eclipse.che.ide.extension.machine.client.processes.ConsolesPanelPresenter;
|
||||
import org.eclipse.che.ide.rest.AsyncRequestCallback;
|
||||
import org.eclipse.che.ide.rest.DtoUnmarshallerFactory;
|
||||
import org.eclipse.che.ide.ui.dialogs.DialogFactory;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
|
||||
import static org.eclipse.che.ide.ext.git.client.history.HistoryPresenter.LOG_COMMAND_NAME;
|
||||
import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode;
|
||||
|
||||
/**
|
||||
* Presenter for resetting head to commit.
|
||||
|
|
@ -50,6 +54,7 @@ public class ResetToCommitPresenter implements ResetToCommitView.ActionDelegate
|
|||
private final DtoUnmarshallerFactory dtoUnmarshallerFactory;
|
||||
private final ResetToCommitView view;
|
||||
private final GitOutputConsoleFactory gitOutputConsoleFactory;
|
||||
private final DialogFactory dialogFactory;
|
||||
private final ConsolesPanelPresenter consolesPanelPresenter;
|
||||
private final GitServiceClient service;
|
||||
private final AppContext appContext;
|
||||
|
|
@ -68,12 +73,14 @@ public class ResetToCommitPresenter implements ResetToCommitView.ActionDelegate
|
|||
GitLocalizationConstant constant,
|
||||
EventBus eventBus,
|
||||
EditorAgent editorAgent,
|
||||
DialogFactory dialogFactory,
|
||||
AppContext appContext,
|
||||
NotificationManager notificationManager,
|
||||
DtoUnmarshallerFactory dtoUnmarshallerFactory,
|
||||
GitOutputConsoleFactory gitOutputConsoleFactory,
|
||||
ConsolesPanelPresenter consolesPanelPresenter) {
|
||||
this.view = view;
|
||||
this.dialogFactory = dialogFactory;
|
||||
this.gitOutputConsoleFactory = gitOutputConsoleFactory;
|
||||
this.consolesPanelPresenter = consolesPanelPresenter;
|
||||
this.view.setDelegate(this);
|
||||
|
|
@ -103,6 +110,12 @@ public class ResetToCommitPresenter implements ResetToCommitView.ActionDelegate
|
|||
|
||||
@Override
|
||||
protected void onFailure(Throwable exception) {
|
||||
if (getErrorCode(exception) == ErrorCodes.INIT_COMMIT_WAS_NOT_PERFORMED) {
|
||||
dialogFactory.createMessageDialog(constant.resetCommitViewTitle(),
|
||||
constant.initCommitWasNotPerformed(),
|
||||
null).show();
|
||||
return;
|
||||
}
|
||||
String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : constant.logFailed();
|
||||
GitOutputConsole console = gitOutputConsoleFactory.create(LOG_COMMAND_NAME);
|
||||
console.printError(errorMessage);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ button.push=Push
|
|||
button.pull=Pull
|
||||
|
||||
############MESSAGES################
|
||||
messages.unableGetSshKeyTitle=Failed to get private ssh key
|
||||
messages.unableGetSshKey = You can create a new SSH key pair in Window->Preferences->Keys->SSH Keystore.
|
||||
messages.unableGetSshKey = Failed to get private ssh key. \
|
||||
You can create a new SSH key pair in Help->Preferences->SSH->Git.
|
||||
messages.warningTitle = Warning
|
||||
messages.index_empty=Index is empty
|
||||
messages.add_success=Git index updated
|
||||
|
|
@ -50,6 +50,7 @@ messages.committer_identity_info_empty=Git user name and (or) email was not set.
|
|||
You can set this information in Help -> Preferences -> Git -> Committer.
|
||||
messages.diff.failed=Failed to get diff
|
||||
messages.log_failed=Failed to load commits history
|
||||
messages.init_commit_was_not_performed=Initial commit is required to perform this operation.
|
||||
messages.init_success=Repository initialized
|
||||
messages.init_failed=Failed to initialize repository
|
||||
messages.initRepoQuestion = Do you want to initialize the local repository {0}?
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public class HistoryPresenterTest extends BaseTest {
|
|||
constant,
|
||||
appContext,
|
||||
notificationManager,
|
||||
dialogFactory,
|
||||
dtoUnmarshallerFactory,
|
||||
dateTimeFormatter,
|
||||
selectionAgent,
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ public class ResetToCommitPresenterTest extends BaseTest {
|
|||
constant,
|
||||
eventBus,
|
||||
editorAgent,
|
||||
dialogFactory,
|
||||
appContext,
|
||||
notificationManager,
|
||||
dtoUnmarshallerFactory,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ authorization.dialog.title = Authorization
|
|||
authorization.dialog.text = {0} requests authorization through OAuth2 protocol
|
||||
authorization.generateKeyLabel = generate ssh key and upload it on GitHub
|
||||
authorization.message.unableCreateSshKey = Unable create private ssh key. \
|
||||
You can create a new SSH key pair in Window->Preferences->Keys->SSH Keystore.
|
||||
You can create a new SSH key pair in Help->Preferences->SSH->Git.
|
||||
authorization.message.keyUploadSuccess = Ssh key uploaded
|
||||
############### SamplesListGrid ###############
|
||||
samplesListGrid.column.name=Project
|
||||
|
|
|
|||
Loading…
Reference in New Issue