use of org.eclipse.egit.core.op.RebaseOperation in project egit by eclipse.
the class RebaseOperationTest method testUpToDate.
@Test
@Ignore
public // currently not working as expected; see also TODO in RebaseCommand
void testUpToDate() throws Exception {
IFile file = project.createFile("theFile.txt", "Hello, world".getBytes("UTF-8"));
// first commit in master: add theFile.txt
RevCommit first = testRepository.addAndCommit(project.project, new File(file.getLocationURI()), "Adding theFile.txt");
testRepository.createBranch(MASTER, TOPIC);
// checkout topic
testRepository.checkoutBranch(TOPIC);
file = project.createFile("theSecondFile.txt", "Hello, world".getBytes("UTF-8"));
// topic commit: add second file
RevCommit topicCommit = testRepository.addAndCommit(project.project, new File(file.getLocationURI()), "Adding theSecondFile.txt");
// parent of topic commit should be first master commit before rebase
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
RebaseOperation op = new RebaseOperation(testRepository.getRepository(), testRepository.getRepository().exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
assertEquals(RebaseResult.Status.UP_TO_DATE, res.getStatus());
try (RevWalk rw = new RevWalk(repository)) {
RevCommit newTopic = rw.parseCommit(repository.resolve(TOPIC));
assertEquals(topicCommit, newTopic);
assertEquals(first, newTopic.getParent(0));
}
}
use of org.eclipse.egit.core.op.RebaseOperation in project egit by eclipse.
the class RebaseOperationTest method testNoConflict.
@Test
public void testNoConflict() throws Exception {
IFile file = project.createFile("theFile.txt", "Hello, world".getBytes("UTF-8"));
// first commit in master: add theFile.txt
RevCommit first = testRepository.addAndCommit(project.project, new File(file.getLocationURI()), "Adding theFile.txt");
testRepository.createBranch(MASTER, TOPIC);
file.setContents(new ByteArrayInputStream("master".getBytes("UTF-8")), 0, null);
// second commit in master: modify theFile.txt
RevCommit second = git.commit().setAll(true).setMessage("Modify theFile.txt").call();
assertEquals(first, second.getParent(0));
// checkout topic
testRepository.checkoutBranch(TOPIC);
file = project.createFile("theSecondFile.txt", "Hello, world".getBytes("UTF-8"));
// topic commit: add second file
RevCommit topicCommit = testRepository.addAndCommit(project.project, new File(file.getLocationURI()), "Adding theSecondFile.txt");
// parent of topic commit should be first master commit before rebase
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
RebaseOperation op = new RebaseOperation(testRepository.getRepository(), testRepository.getRepository().exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
assertEquals(RebaseResult.Status.OK, res.getStatus());
try (RevWalk rw = new RevWalk(repository)) {
RevCommit newTopic = rw.parseCommit(repository.resolve(TOPIC));
assertEquals(second, newTopic.getParent(0));
}
}
use of org.eclipse.egit.core.op.RebaseOperation in project egit by eclipse.
the class FeatureRebaseOperation method execute.
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
try {
if (!repository.isFeature()) {
throw new WrongGitFlowStateException(CoreText.FeatureRebaseOperation_notOnAFeatureBranch);
}
Repository jgitRepo = repository.getRepository();
Ref develop = jgitRepo.exactRef(repository.getConfig().getDevelopFull());
RebaseOperation op = new RebaseOperation(jgitRepo, develop);
op.execute(monitor);
operationResult = op.getResult();
} catch (WrongGitFlowStateException | IOException e) {
throw new CoreException(error(e.getMessage(), e));
}
}
use of org.eclipse.egit.core.op.RebaseOperation in project egit by eclipse.
the class RebaseCurrentRefCommand method createRebaseOperation.
@Override
protected RebaseOperation createRebaseOperation(Repository repository) throws ExecutionException {
if (LaunchFinder.shouldCancelBecauseOfRunningLaunches(repository, null)) {
return null;
}
InteractiveHandler handler = interactive ? RebaseInteractiveHandler.INSTANCE : null;
RebaseOperation operation = new RebaseOperation(repository, ref, handler);
operation.setPreserveMerges(preserveMerges);
return operation;
}
use of org.eclipse.egit.core.op.RebaseOperation in project egit by eclipse.
the class RebaseOperationTest method testExceptionWhenRestartingStoppedRebase.
@Test
public void testExceptionWhenRestartingStoppedRebase() throws Exception {
IFile file = project.createFile("theFile.txt", "Hello, world".getBytes("UTF-8"));
// first commit in master: add theFile.txt
RevCommit first = testRepository.addAndCommit(project.project, new File(file.getLocationURI()), "Adding theFile.txt");
testRepository.createBranch(MASTER, TOPIC);
file.setContents(new ByteArrayInputStream("master".getBytes("UTF-8")), 0, null);
// second commit in master: modify theFile.txt
RevCommit second = git.commit().setAll(true).setMessage("Modify theFile.txt").call();
assertEquals(first, second.getParent(0));
// checkout topic
testRepository.checkoutBranch(TOPIC);
// set conflicting content in topic
file.setContents(new ByteArrayInputStream("topic".getBytes("UTF-8")), 0, null);
// topic commit: add second file
RevCommit topicCommit = testRepository.addAndCommit(project.project, new File(file.getLocationURI()), "Changing theFile.txt again");
// parent of topic commit should be first master commit before rebase
assertEquals(first, topicCommit.getParent(0));
// rebase topic onto master
RebaseOperation op = new RebaseOperation(repository, repository.exactRef(MASTER));
op.execute(null);
RebaseResult res = op.getResult();
assertEquals(RebaseResult.Status.STOPPED, res.getStatus());
try {
// let's try to start again, we should get a wrapped
// WrongRepositoryStateException
op = new RebaseOperation(repository, repository.exactRef(MASTER));
op.execute(null);
fail("Expected Exception not thrown");
} catch (CoreException e) {
Throwable cause = e.getCause();
assertTrue(cause instanceof WrongRepositoryStateException);
}
}
Aggregations