GitCloneTask implements Task { @Override public void run(TaskQueue tasks) throws Throwable { if (git.exists()) { LOG.info("git clone already performed, issuing pull instead."); tasks.insertAtHead(new GitPullRemoteTask(git)); return; } git.clone(remoteUrl); } GitCloneTask(IGit git, String url); @Override String getName(); @Override void run(TaskQueue tasks);  }
@Test public void testCloneAndBranchLauncher() throws Throwable { testdir.ensureEmpty(); GitMirrors mirrors = GitMirrors.load(); GitFactory.setMirrors(mirrors); WorkDir workdir = new WorkDir(testdir.getFile("work")); Repo repo = new Repo(); repo.setUrl("git: String branchName = "android-sdk-2.0.1_r1"; IGit git = workdir.getGitRepo(repo.getUrl()); GitCloneTask gitclone = new GitCloneTask(git, repo.getUrl()); GitSwitchBranchTask gitbranch = new GitSwitchBranchTask(git, branchName); TaskQueue tasks = new TaskQueue(); gitclone.run(tasks); gitbranch.run(tasks); Assert.assertThat("Branch name", git.getCurrentBranch(), is("refs/tags/" + branchName)); }