use of org.eclipse.che.api.git.shared.ResetRequest in project che by eclipse.
the class GitServiceClientImpl method reset.
@Override
public void reset(DevMachine devMachine, ProjectConfigDto project, String commit, @Nullable ResetRequest.ResetType resetType, @Nullable List<String> filePattern, AsyncRequestCallback<Void> callback) {
ResetRequest resetRequest = dtoFactory.createDto(ResetRequest.class).withCommit(commit);
if (resetType != null) {
resetRequest.setType(resetType);
}
if (filePattern != null) {
resetRequest.setFilePattern(filePattern);
}
String url = appContext.getDevMachine().getWsAgentBaseUrl() + RESET + "?projectPath=" + project.getPath();
asyncRequestFactory.createPostRequest(url, resetRequest).loader(loader).send(callback);
}
use of org.eclipse.che.api.git.shared.ResetRequest in project che by eclipse.
the class GitServiceClientImpl method reset.
@Override
public Promise<Void> reset(DevMachine devMachine, Path project, String commit, ResetRequest.ResetType resetType, Path[] files) {
ResetRequest resetRequest = dtoFactory.createDto(ResetRequest.class).withCommit(commit);
if (resetType != null) {
resetRequest.setType(resetType);
}
if (files != null) {
List<String> fileList = new ArrayList<>(files.length);
for (Path file : files) {
fileList.add(file.isEmpty() ? "." : file.toString());
}
resetRequest.setFilePattern(fileList);
}
String url = devMachine.getWsAgentBaseUrl() + RESET + "?projectPath=" + project;
return asyncRequestFactory.createPostRequest(url, resetRequest).loader(loader).send();
}
use of org.eclipse.che.api.git.shared.ResetRequest in project che by eclipse.
the class ResetTest method testResetMixed.
@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testResetMixed(GitConnectionFactory connectionFactory) throws Exception {
//given
GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
File aaa = addFile(connection, "aaa", "aaa\n");
FileOutputStream fos = new FileOutputStream(new File(connection.getWorkingDir(), "README.txt"));
fos.write("MODIFIED\n".getBytes());
fos.flush();
fos.close();
String initMessage = connection.log(LogParams.create()).getCommits().get(0).getMessage();
connection.add(AddParams.create(new ArrayList<>(singletonList("."))));
connection.commit(CommitParams.create("add file"));
//when
ResetRequest resetRequest = newDto(ResetRequest.class).withCommit("HEAD^");
connection.reset(ResetParams.create("HEAD^", ResetRequest.ResetType.MIXED));
//then
assertEquals(connection.log(LogParams.create()).getCommits().get(0).getMessage(), initMessage);
assertTrue(aaa.exists());
assertEquals(connection.status(StatusFormat.SHORT).getUntracked().get(0), "aaa");
assertEquals(connection.status(StatusFormat.SHORT).getModified().get(0), "README.txt");
assertEquals(Files.toString(new File(connection.getWorkingDir(), "README.txt"), Charsets.UTF_8), "MODIFIED\n");
}
Aggregations