use of io.fabric8.api.GitContext in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method pushLocalBranchAheadAndNotClean.
@Test
public void pushLocalBranchAheadAndNotClean() throws IOException, GitAPIException {
local.checkout().setName("1.1").setCreateBranch(false).call();
editVersion("1.1", 4, false);
FileUtils.write(new File(dirLocal, "newFile.txt"), "~");
FileUtils.write(new File(dirLocal, "fabric/profiles/default.profile/my.special.pid.properties"), "\n# new line", true);
assertFalse(local.status().call().isClean());
PullPushPolicy.PushPolicyResult result = policy.doPush(new GitContext(), CP);
assertNull(result.getLastException());
// push to only one remote, so one PushResult
PushResult pr = result.getPushResults().get(0);
assertThat(pr.getRemoteUpdate("refs/heads/1.0").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/1.0.1").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/1.1").getStatus(), equalTo(RemoteRefUpdate.Status.OK));
assertThat(pr.getRemoteUpdate("refs/heads/1.2").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/master").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/tags/root").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertTrue(local.status().call().isClean());
}
use of io.fabric8.api.GitContext in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method remoteRemovalOfSingleBranch.
@Test
public void remoteRemovalOfSingleBranch() throws GitAPIException {
servlet.branchDelete().setForce(true).setBranchNames("1.1").call();
PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true);
assertNull(result.getLastException());
List<String> versions = new ArrayList<>(result.getVersions());
// these are sorted (TreeSet)
assertThat(versions.size(), equalTo(4));
assertThat(versions.get(0), equalTo("1.0"));
assertThat(versions.get(1), equalTo("1.0.1"));
assertThat(versions.get(2), equalTo("1.2"));
assertThat(versions.get(3), equalTo("master"));
List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
assertThat(localUpdateVersions.size(), equalTo(1));
assertThat(localUpdateVersions.get(0), equalTo("1.1"));
assertFalse(result.remoteUpdateRequired());
List<Ref> localBranches = local.branchList().call();
assertThat(localBranches.size(), equalTo(4));
}
use of io.fabric8.api.GitContext in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method pushLocalBranchAheadRemoteIsAlsoAhead.
@Test
public void pushLocalBranchAheadRemoteIsAlsoAhead() throws IOException, GitAPIException {
local.checkout().setName("1.1").setCreateBranch(false).call();
local.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD^").call();
editVersion("1.1", 2, false);
assertTrue(local.status().call().isClean());
PullPushPolicy.PushPolicyResult result = policy.doPush(new GitContext(), CP);
assertNull(result.getLastException());
// push to only one remote, so one PushResult
PushResult pr = result.getPushResults().get(0);
assertThat(result.getAcceptedUpdates().size(), equalTo(5));
assertThat(pr.getRemoteUpdate("refs/heads/1.0").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/1.0.1").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/1.1").getStatus(), equalTo(RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD));
assertThat(pr.getRemoteUpdate("refs/heads/1.2").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/master").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/tags/root").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(result.getRejectedUpdates().size(), equalTo(1));
assertThat(result.getRejectedUpdates().get("refs/heads/1.1").getRemoteRefUpdate().getStatus(), equalTo(RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD));
assertEquals(local.getRepository().getRef("1.1").getName(), servlet.getRepository().getRef("1.1").getName());
assertTrue(local.status().call().isClean());
}
use of io.fabric8.api.GitContext in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method remoteUpdateWhenLocalBranchIsAheadButNoPushIsAllowed.
@Test
public void remoteUpdateWhenLocalBranchIsAheadButNoPushIsAllowed() throws GitAPIException, IOException {
editVersion("1.1", 2, true, "fabric/profiles/default.profile/io.fabric8.other.properties");
editVersion("1.1", 2, false);
ObjectId branch1_1local = local.getRepository().getRef("refs/heads/1.1").getObjectId();
ObjectId branch1_1remote = servlet.getRepository().getRef("refs/heads/1.1").getObjectId();
assertThat(branch1_1local, not(equalTo(branch1_1remote)));
local.checkout().setName("1.0").setCreateBranch(false).call();
assertTrue(local.status().call().isClean());
PullPushPolicy.PullPolicyResult result = policy.doPull(new GitContext(), CP, true, false);
assertNull(result.getLastException());
List<String> versions = new ArrayList<>(result.getVersions());
// these are sorted (TreeSet)
assertThat(versions.size(), equalTo(5));
assertThat(versions.get(0), equalTo("1.0"));
assertThat(versions.get(1), equalTo("1.0.1"));
assertThat(versions.get(2), equalTo("1.1"));
assertThat(versions.get(3), equalTo("1.2"));
assertThat(versions.get(4), equalTo("master"));
List<String> localUpdateVersions = new ArrayList<>(result.localUpdateVersions().keySet());
assertThat(localUpdateVersions.size(), equalTo(1));
assertThat(localUpdateVersions.get(0), equalTo("1.1"));
assertFalse(result.remoteUpdateRequired());
assertTrue(local.status().call().isClean());
List<Ref> localBranches = local.branchList().call();
assertThat(localBranches.size(), equalTo(5));
assertNotNull(local.getRepository().getRef("1.1"));
assertThat("Local branch should change (will be reset to remote)", local.getRepository().getRef("refs/heads/1.1").getObjectId(), equalTo(branch1_1remote));
}
use of io.fabric8.api.GitContext in project fabric8 by jboss-fuse.
the class PushPullPolicyIT method pushLocalBranchAheadRemoteIsRemoved.
@Test
public void pushLocalBranchAheadRemoteIsRemoved() throws IOException, GitAPIException {
local.checkout().setName("1.1").setCreateBranch(false).call();
editVersion("1.1", 3, false);
servlet.branchDelete().setForce(true).setBranchNames("1.1").call();
assertTrue(local.status().call().isClean());
PullPushPolicy.PushPolicyResult result = policy.doPush(new GitContext(), CP);
assertNull(result.getLastException());
// push to only one remote, so one PushResult
PushResult pr = result.getPushResults().get(0);
assertThat(result.getAcceptedUpdates().size(), equalTo(6));
assertThat(pr.getRemoteUpdate("refs/heads/1.0").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/1.0.1").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/1.1").getStatus(), equalTo(RemoteRefUpdate.Status.OK));
assertThat(pr.getRemoteUpdate("refs/heads/1.2").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/heads/master").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(pr.getRemoteUpdate("refs/tags/root").getStatus(), equalTo(RemoteRefUpdate.Status.UP_TO_DATE));
assertThat(result.getRejectedUpdates().size(), equalTo(0));
assertEquals(local.getRepository().getRef("1.1").getName(), servlet.getRepository().getRef("1.1").getName());
assertTrue(local.status().call().isClean());
}
Aggregations