@Test public void shouldNotBeAheadAfterPush() throws Exception { String fileName = "a.txt"; String fileContent = "*****@*****.**"; File file = testRepository.createFile(fileName, fileContent); testRepository.addAndCommit(file, "adding a file"); testRepository.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository()); assertTrue(EGitUtils.isAhead(testRepository.getRepository(), REPO2_REMOTE_NAME, null)); EGitUtils.pushForce(REPO2_REMOTE_NAME, testRepository.getRepository(), null); assertFalse(EGitUtils.isAhead(testRepository.getRepository(), REPO2_REMOTE_NAME, null)); }
@Test public void shouldReturnThatCloneIsAhead() throws Exception { assertFalse( EGitUtils.isAhead( testRepositoryClone.getRepository(), Constants.DEFAULT_REMOTE_NAME, null)); String fileName = "c.txt"; String fileContent = "*****@*****.**"; File file = testRepositoryClone.createFile(fileName, fileContent); testRepositoryClone.addAndCommit(file, "adding a file"); assertTrue( EGitUtils.isAhead( testRepositoryClone.getRepository(), Constants.DEFAULT_REMOTE_NAME, null)); }
@Test public void shouldReturnThatCloneIsAheadOfRemote() throws Exception { testRepositoryClone.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository()); new Git(testRepositoryClone.getRepository()) .push() .setRemote(REPO2_REMOTE_NAME) .setForce(true) .call(); assertFalse(EGitUtils.isAhead(testRepositoryClone.getRepository(), REPO2_REMOTE_NAME, null)); String fileName = "c.txt"; String fileContent = "*****@*****.**"; File file = testRepositoryClone.createFile(fileName, fileContent); testRepositoryClone.addAndCommit(file, "adding a file"); assertTrue(EGitUtils.isAhead(testRepositoryClone.getRepository(), REPO2_REMOTE_NAME, null)); new Git(testRepositoryClone.getRepository()).push().setForce(true).call(); assertTrue(EGitUtils.isAhead(testRepositoryClone.getRepository(), REPO2_REMOTE_NAME, null)); }
@Test public void shouldUserFetchSpecInConfig() throws Exception { testRepository.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository()); // add custom fetch-spec in config (fetch = refs/heads/master:refs/remotes/bingo/master) StoredConfig config = testRepository.getRepository().getConfig(); config.getString(ConfigConstants.CONFIG_KEY_REMOTE, REPO2_REMOTE_NAME, "fetch"); String remoteTrackingBranchRef = "refs/remotes/bingo/master"; String fetchSpec = "refs/heads/master:" + remoteTrackingBranchRef; config.setString(ConfigConstants.CONFIG_KEY_REMOTE, REPO2_REMOTE_NAME, "fetch", fetchSpec); config.save(); EGitUtils.isAhead(testRepository.getRepository(), REPO2_REMOTE_NAME, null); // was remote tracking branch created? assertTrue(testRepository.getRepository().getAllRefs().containsKey(remoteTrackingBranchRef)); }