Beispiel #1
0
 @Test(
     dataProvider = "GitConnectionFactory",
     dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
 public void testResetSoft(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(newDto(LogRequest.class)).getCommits().get(0).getMessage();
   connection.add(newDto(AddRequest.class).withFilepattern(new ArrayList<>(Arrays.asList("."))));
   connection.commit(newDto(CommitRequest.class).withMessage("add file"));
   // when
   ResetRequest resetRequest = newDto(ResetRequest.class).withCommit("HEAD^");
   resetRequest.setType(ResetRequest.ResetType.SOFT);
   connection.reset(resetRequest);
   // then
   assertEquals(
       connection.log(newDto(LogRequest.class)).getCommits().get(0).getMessage(), initMessage);
   assertTrue(aaa.exists());
   assertEquals(connection.status(StatusFormat.SHORT).getAdded().get(0), "aaa");
   assertEquals(connection.status(StatusFormat.SHORT).getChanged().get(0), "README.txt");
   assertEquals(
       Files.toString(new File(connection.getWorkingDir(), "README.txt"), Charsets.UTF_8),
       "MODIFIED\n");
 }
Beispiel #2
0
 @Override
 public void reset(ResetRequest request) throws GitException {
   nativeGit
       .createResetCommand()
       .setMode(request.getType().getValue())
       .setCommit(request.getCommit())
       .setFilePattern(request.getFilePattern())
       .execute();
 }
 @Override
 public void reset(ResetRequest request) throws GitException {
   ensureExistenceRepoRootInWorkingDirectory();
   nativeGit
       .createResetCommand()
       .setMode(request.getType().getValue())
       .setCommit(request.getCommit())
       .setFilePattern(request.getFilePattern())
       .execute();
 }