use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class GitLabelingSupportTest method fail_labeling_when_heuristics_fails.
public void fail_labeling_when_heuristics_fails() throws Exception {
myConfig.setUsePackHeuristic(true);
myConfig.setFailLabelingWhenPackHeuristicsFail(true);
GitVcsSupport git = buildGit();
File remoteRepoDir = getRemoteRepositoryDir("repo_for_fetch.2");
VcsRoot root = vcsRoot().withFetchUrl(remoteRepoDir).build();
makeCloneOnServer(git, root);
// erase commit in the remote repository
FileUtil.delete(remoteRepoDir);
remoteRepoDir.mkdirs();
FileUtil.copyDir(getRemoteRepositoryDir("repo_for_fetch.1"), remoteRepoDir);
try {
// label erased commit
String erasedCommit = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
git.getLabelingSupport().label("label", erasedCommit, root, CheckoutRules.DEFAULT);
fail("Should fail labeling since heuristics fails");
} catch (VcsException e) {
assertTrue(true);
}
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class GitLabelingSupportTest method should_push_all_objects_missing_in_remote_repository.
@Test(dataProvider = "true,false")
public void should_push_all_objects_missing_in_remote_repository(boolean usePackHeuristics) throws Exception {
myConfig.setUsePackHeuristic(usePackHeuristics);
GitVcsSupport git = buildGit();
File remoteRepoDir = getRemoteRepositoryDir("repo_for_fetch.2");
VcsRoot root = vcsRoot().withFetchUrl(remoteRepoDir).build();
makeCloneOnServer(git, root);
// erase commit in the remote repository
FileUtil.delete(remoteRepoDir);
remoteRepoDir.mkdirs();
FileUtil.copyDir(getRemoteRepositoryDir("repo_for_fetch.1"), remoteRepoDir);
// label erased commit
String erasedCommit = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
git.getLabelingSupport().label("label", erasedCommit, root, CheckoutRules.DEFAULT);
// erased commit should appear in the remote repository
Repository r = new RepositoryBuilder().setGitDir(remoteRepoDir).build();
RevWalk walk = new RevWalk(r);
try {
walk.parseCommit(ObjectId.fromString(erasedCommit));
} catch (MissingObjectException e) {
fail("Not all objects were pushed, labeled commit " + erasedCommit + " is missing");
} finally {
walk.close();
r.close();
}
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class GitPatchTest method submodules_and_checkout_rules4.
@TestFor(issues = "TW-50097")
@Test(dataProvider = "patchInSeparateProcess")
public void submodules_and_checkout_rules4(boolean patchInSeparateProcess) throws Exception {
myConfigBuilder.setSeparateProcessForPatch(patchInSeparateProcess);
VcsRoot root = getRoot("sub-submodule", true);
checkPatch(root, "submodules_and_checkout_rules4", null, "ce6044093939bb47283439d97a1c80f759669ff5", new CheckoutRules("+:first-level-submodule/sub-sub/file.txt"));
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class CleanerTest method nonInplaceGc.
public void nonInplaceGc() throws Exception {
myConfigBuilder.setRunNativeGC(true);
myConfigBuilder.setRunInPlaceGc(false);
initCleanup();
VcsRoot root = GitTestUtil.getVcsRoot();
// clone repository
mySupport.collectChanges(root, "70dbcf426232f7a33c7e5ebdfbfb26fc8c467a46", "a894d7d58ffde625019a9ecf8267f5f1d1e5c341", CheckoutRules.DEFAULT);
File repositoryDir = getRepositoryDir(root);
// create more than 50 packs to trigger gc:
File packDir = new File(repositoryDir, "objects/pack");
final File[] packs = FileUtil.listFiles(packDir, (dir, name) -> name.startsWith("pack-") && name.endsWith(".pack"));
assertTrue(packs.length > 0);
File pack = packs[0];
File idx = new File(packDir, StringUtil.replace(pack.getName(), ".pack", ".idx"));
for (int i = 10; i <= 60; i++) {
final File newPack = new File(packDir, "pack-" + i + "63fffad1c368b0a79f9a196ee098e303fc0c29.pack");
final File newIdx = new File(packDir, "pack-" + i + "63fffad1c368b0a79f9a196ee098e303fc0c29.idx");
if (newPack.isFile() || newIdx.isFile())
continue;
FileUtil.copy(pack, newPack);
FileUtil.copy(idx, newIdx);
}
FileRepository db = (FileRepository) new RepositoryBuilder().setGitDir(repositoryDir).build();
then(db.getObjectDatabase().getPacks().size() > 50).isTrue();
myCleanup.run();
db = (FileRepository) new RepositoryBuilder().setGitDir(repositoryDir).build();
then(db.getObjectDatabase().getPacks().size()).isEqualTo(1);
}
use of jetbrains.buildServer.vcs.VcsRoot in project teamcity-git by JetBrains.
the class TestConnectionTest method should_failed_when_branch_not_found.
public void should_failed_when_branch_not_found() throws Exception {
try {
VcsRoot root = vcsRoot().withFetchUrl(getRemoteRepositoryUrl("repo.git")).withBranch("no-such-branch").build();
myGit.testConnection(root);
fail("Test connection should fail for unknown branch");
} catch (VcsException ex) {
assertTrue(true);
}
}
Aggregations