/** * Constructs a new {@code SymRef} with the given name and target reference. * * @param name the name of the symbolic reference * @param target the reference that this symbolic ref points to */ public SymRef(String name, Ref target) { super(name, target.getObjectId()); this.target = target.getName(); }
static CompletableFuture<Integer> countMissingCommits(Ref oldTip, Ref newTip, Context context) { if (oldTip.getObjectId().equals(newTip.getObjectId())) { return CompletableFuture.completedFuture(Integer.valueOf(0)); } return CompletableFuture.supplyAsync(() -> { Iterator<RevCommit> missingCommits = context.command(LogOp.class) .setUntil(newTip.getObjectId()).setSince(oldTip.getObjectId()).call(); int commitsBehind = Iterators.size(missingCommits); return commitsBehind; }); }
@Override public boolean apply(@Nullable Ref ref) { String refName = ref.getName(); ObjectId refId = ref.getObjectId(); return refName.startsWith(Ref.HEADS_PREFIX) && refId.equals(this.id); } };
@Override public boolean apply(@Nullable Ref ref) { String refName = ref.getName(); ObjectId refId = ref.getObjectId(); return refName.startsWith(Ref.HEADS_PREFIX) && refId.equals(this.id); } };
/** * @param o object to compare against * @return whether or not this ref is equal to the target object */ @Override public boolean equals(Object o) { if (!(o instanceof Ref)) { return false; } Ref r = (Ref) o; return name.equals(r.getName()) && objectId.equals(r.getObjectId()); }
@Override protected ImmutableList<RevTag> _call() { List<Ref> refs = newArrayList( command(ForEachRef.class).setPrefixFilter(Ref.TAGS_PREFIX).call()); List<ObjectId> tagIds = transform(refs, (r) -> r.getObjectId()); Iterator<RevTag> alltags; alltags = objectDatabase().getAll(tagIds, BulkOpListener.NOOP_LISTENER, RevTag.class); ImmutableList<RevTag> res = ImmutableList.copyOf(alltags); return res; }
private void testRsolvePartial(String refSpec, String refName) { Optional<Ref> ref; ref = command.setName(refSpec).call(); assertTrue(ref.isPresent()); assertEquals(refName, ref.get().getName()); assertEquals(RevObjectTestSupport.hashString(refName), ref.get().getObjectId()); }
public @Test void prepareUpToDateNoConflicts() { PRStatus result = prepare(); assertTrue(result.getReport().isPresent()); MergeScenarioReport mergeReport = result.getReport().get(); assertNotNull(mergeReport); assertTrue(result.getMergeCommit().isPresent()); ObjectId mergeCommitId = result.getMergeCommit().get(); GeogigTransaction prtx = getTransaction(); Optional<Ref> mergeRef = request.resolveMergeRef(prtx); assertTrue(mergeRef.isPresent()); assertEquals(mergeCommitId, mergeRef.get().getObjectId()); }
public TestData mergeNoFF(String branchToMerge, String mergeCommitMessage) { ObjectId branchHead = getContext().command(RefParse.class).setName(branchToMerge).call() .get().getObjectId(); MergeReport report = getContext().command(MergeOp.class).setNoFastForward(true) .setMessage(mergeCommitMessage).addCommit(branchHead).call(); RevCommit mergeCommit = report.getMergeCommit(); checkState(mergeCommit.getParentIds().size() == 2); LOG.debug(mergeCommit.toString()); return this; }
@Test public void testRebaseNoCommits() throws Exception { Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); exception.expect(IllegalStateException.class); geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(master.get().getObjectId())) .call(); }
@Test public void testRebaseNoCommits() throws Exception { Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); exception.expect(IllegalStateException.class); geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(master.get().getObjectId())) .call(); }
@Test public void testCreateBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call(); assertTrue(branch1.isPresent()); Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); assertEquals(master.get().getObjectId(), branch1.get().getObjectId()); }
@Test public void testCreateBranch() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true).call(); Optional<Ref> branch1 = geogig.command(RefParse.class).setName("branch1").call(); assertTrue(branch1.isPresent()); Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); assertEquals(master.get().getObjectId(), branch1.get().getObjectId()); }
private void fakeUpToDate() { Remote remote = request.buildRemote(); GeogigTransaction tx = request.getTransaction(origin.getRepo().context()); tx.command(FetchOp.class).setFetchIndexes(true).addRemote(remote).call(); Ref remoteBranchState = clone.getRef(request.getRemoteBranch()); Ref localRemoteBranchState = tx.command(RefParse.class).setName(request.getOriginRef()) .call().get(); assertEquals(remoteBranchState.getObjectId(), localRemoteBranchState.getObjectId()); } }
@Test public void testRebaseNoUpstreamCommit() throws Exception { Optional<Ref> master = geogig.command(RefParse.class).setName("master").call(); insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("commit for " + idP1).call(); exception.expect(IllegalStateException.class); geogig.command(RebaseOp.class).setUpstream(Suppliers.ofInstance(master.get().getObjectId())) .call(); }
@Given("^I have a remote ref called \"([^\"]*)\"$") public void i_have_a_remote_ref_called(String expected) throws Throwable { String ref = "refs/remotes/origin/" + expected; localRepo.geogigCLI.getGeogig(Hints.readWrite()).command(UpdateRef.class).setName(ref) .setNewValue(ObjectId.NULL).call(); Optional<Ref> refValue = localRepo.geogigCLI.getGeogig(Hints.readWrite()) .command(RefParse.class).setName(ref).call(); assertTrue(refValue.isPresent()); assertEquals(refValue.get().getObjectId(), ObjectId.NULL); }
@Given("^I have a merge conflict state$") public void I_have_a_merge_conflict_state() throws Throwable { I_have_conflicting_branches(); Ref branch = localRepo.geogigCLI.getGeogig(Hints.readOnly()).command(RefParse.class) .setName("branch1").call().get(); try { localRepo.geogigCLI.getGeogig(Hints.readWrite()).command(MergeOp.class) .addCommit(branch.getObjectId()).call(); fail(); } catch (MergeConflictsException e) { } }
@Test public void testSymRef() { Ref testRef = new Ref(Ref.REFS_PREFIX + "commit1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000")); SymRef symRef = new SymRef("TestRef", testRef); assertEquals(testRef.getName(), symRef.getTarget()); String symRefString = symRef.toString(); assertEquals("TestRef -> " + "[" + testRef.getName() + " -> " + testRef.getObjectId().toString() + "]", symRefString); } }
@Test public void testConstructorAndMutators() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); Ref branch = geogig.command(BranchCreateOp.class).setName("branch1").call(); geogig.command(UpdateSymRef.class).setDelete(false).setName(Ref.HEAD) .setNewValue("refs/heads/branch1").setOldValue(Ref.MASTER) .setReason("this is a test").call(); Optional<ObjectId> branchId = geogig.command(RevParse.class).setRefSpec(Ref.HEAD).call(); assertTrue(branch.getObjectId().equals(branchId.get())); }
@Test public void testOrphan() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).setMessage("Commit1").call(); Ref branch1 = geogig.command(BranchCreateOp.class).setName("branch1").setAutoCheckout(true) .setOrphan(true).call(); assertEquals(ObjectId.NULL, branch1.getObjectId()); assertEquals(Ref.HEADS_PREFIX + "branch1", branch1.getName()); } }