use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method should_remove_orphaned_indexes.
@TestFor(issues = "TW-40313")
public void should_remove_orphaned_indexes() throws Exception {
// checkout
VcsRootImpl root = vcsRoot().withAgentGitPath(getGitPath()).withFetchUrl(GitUtils.toURL(myMainRepo)).build();
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", myCheckoutDir, createRunningBuild(true), false);
// create orphaned idx files
File mirror = myBuilder.getMirrorManager().getMirrorDir(GitUtils.toURL(myMainRepo));
File idxInMirror = new File(new File(new File(mirror, "objects"), "pack"), "whatever.idx");
writeFileAndReportErrors(idxInMirror, "whatever");
File idxInCheckoutDir = new File(new File(new File(mirror, "objects"), "pack"), "whatever.idx");
writeFileAndReportErrors(idxInCheckoutDir, "whatever");
// checkout again
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "465ad9f630e451b9f2b782ffb09804c6a98c4bb9", myCheckoutDir, createRunningBuild(true), false);
// orphaned idx files are removed
then(idxInCheckoutDir).doesNotExist();
then(idxInMirror).doesNotExist();
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method test_update_on_revision_from_feature_branch.
@Test(dataProvider = "mirrors")
public void test_update_on_revision_from_feature_branch(Boolean useMirrors) throws Exception {
AgentRunningBuild build = createRunningBuild(useMirrors);
final File remote = myTempFiles.createTempDir();
copyRepository(dataFile("repo_for_fetch.2.personal"), remote);
VcsRootImpl root = createRoot(remote, "master");
String commitFromFeatureBranch = "d47dda159b27b9a8c4cee4ce98e4435eb5b17168";
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, commitFromFeatureBranch, myCheckoutDir, build, false);
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method recover_from_ref_lock_during_fetch.
@TestFor(issues = "TW-31381")
public void recover_from_ref_lock_during_fetch() throws Exception {
File repo = dataFile("repo_for_fetch.2.personal");
File remoteRepo = myTempFiles.createTempDir();
copyRepository(repo, remoteRepo);
final String fetchUrl = GitUtils.toURL(remoteRepo);
VcsRootImpl root = vcsRoot().withBranch("refs/heads/master").withAgentGitPath(getGitPath()).withFetchUrl(fetchUrl).build();
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "add81050184d3c818560bdd8839f50024c188586", myCheckoutDir, myBuild, false);
// update remote branch master
delete(remoteRepo);
File updatedRepo = dataFile("repo_for_fetch.2");
copyRepository(updatedRepo, remoteRepo);
File mirror = myBuilder.getMirrorManager().getMirrorDir(fetchUrl);
FileUtil.createIfDoesntExist(new File(mirror, "refs/heads/master.lock"));
FileUtil.createIfDoesntExist(new File(myCheckoutDir, ".git/refs/heads/master.lock"));
FileUtil.createIfDoesntExist(new File(myCheckoutDir, ".git/refs/remotes/origin/master.lock"));
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "d47dda159b27b9a8c4cee4ce98e4435eb5b17168", myCheckoutDir, myBuild, false);
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method when_fetch_for_mirror_failed_remove_it_and_try_again.
public void when_fetch_for_mirror_failed_remove_it_and_try_again() throws Exception {
File repo = dataFile("repo_for_fetch.1");
File remoteRepo = myTempFiles.createTempDir();
copyRepository(repo, remoteRepo);
VcsRootImpl root = vcsRoot().withAgentGitPath(getGitPath()).withFetchUrl(GitUtils.toURL(remoteRepo)).build();
AgentRunningBuild buildWithMirrors = createRunningBuild(true);
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "add81050184d3c818560bdd8839f50024c188586", myCheckoutDir, buildWithMirrors, false);
// create branch tmp in the mirror
File mirror = myBuilder.getMirrorManager().getMirrorDir(GitUtils.toURL(remoteRepo));
Repository r = new RepositoryBuilder().setBare().setGitDir(mirror).build();
RefUpdate update = r.updateRef("refs/heads/tmp");
update.setNewObjectId(ObjectId.fromString("add81050184d3c818560bdd8839f50024c188586"));
update.update();
// update remote repo
delete(remoteRepo);
File updatedRepo = dataFile("repo_for_fetch.2.personal");
copyRepository(updatedRepo, remoteRepo);
// create branch tmp/1 in remote repo, so fetch will fail
r = new RepositoryBuilder().setBare().setGitDir(remoteRepo).build();
update = r.updateRef("refs/heads/tmp/1");
update.setNewObjectId(ObjectId.fromString("d47dda159b27b9a8c4cee4ce98e4435eb5b17168"));
update.update();
// update succeeds
myVcsSupport.updateSources(root, CheckoutRules.DEFAULT, "d47dda159b27b9a8c4cee4ce98e4435eb5b17168", myCheckoutDir, buildWithMirrors, false);
}
use of jetbrains.buildServer.vcs.impl.VcsRootImpl in project teamcity-git by JetBrains.
the class AgentVcsSupportTest method should_do_fetch_if_ref_is_outdated.
@Test(dataProvider = "mirrors")
public void should_do_fetch_if_ref_is_outdated(Boolean useMirrors) throws Exception {
AgentRunningBuild build = createRunningBuild(useMirrors);
final File remote = myTempFiles.createTempDir();
copyRepository(dataFile("repo_for_fetch.2.personal"), remote);
VcsRootImpl masterRoot = createRoot(remote, "master");
VcsRootImpl personalRoot = createRoot(remote, "personal");
myVcsSupport.updateSources(personalRoot, new CheckoutRules(""), "d47dda159b27b9a8c4cee4ce98e4435eb5b17168@1303829462000", myCheckoutDir, build, false);
myVcsSupport.updateSources(masterRoot, new CheckoutRules(""), "add81050184d3c818560bdd8839f50024c188586@1303829295000", myCheckoutDir, build, false);
FileUtil.delete(remote);
copyRepository(dataFile("repo_for_fetch.2"), remote);
myVcsSupport.updateSources(masterRoot, new CheckoutRules(""), "d47dda159b27b9a8c4cee4ce98e4435eb5b17168@1303829462000", myCheckoutDir, build, false);
}
Aggregations