private String resolveCommitterEmail() { final String key = "user.email"; Optional<String> email = command(ConfigGet.class).setName(key).call(); checkState(email.isPresent(), "%s not found in config. Use geogig config [--global] %s <your email> to configure it.", key, key); return email.get(); } }
private String resolveCommitter() { final String key = "user.name"; Optional<String> name = command(ConfigGet.class).setName(key).call(); checkState(name.isPresent(), "%s not found in config. Use geogig config [--global] %s <your name> to configure it.", key, key); return name.get(); }
private String resolveCommitterEmail() { final String emailkey = "user.email"; String email = getClientData(emailkey, String.class) .or(command(ConfigGet.class).setName(emailkey).call()).orNull(); checkState(email != null, "%s not found in config. Use geogig config [--global] %s <your email> to configure it.", emailkey, emailkey); return email; } }
private String resolveCommitter() { final String namekey = "user.name"; String name = getClientData(namekey, String.class) .or(command(ConfigGet.class).setName(namekey).call()).orNull(); checkState(name != null, "%s not found in config. Use geogig config [--global] %s <your name> to configure it.", namekey, namekey); return name; }
protected Boolean _call() { final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call(); Preconditions.checkState(currHead.isPresent(), "Repository has no HEAD, can't revert."); Preconditions.checkState(currHead.get() instanceof SymRef, "Cannot run operation while merge conflicts exist."); Optional<Ref> ref = command(RefParse.class).setName(Ref.ORIG_HEAD).call(); if (abort) { Preconditions.checkState(ref.isPresent(), "Cannot abort. You are not in the middle of a revert process."); command(ResetOp.class).setMode(ResetMode.HARD) .setCommit(Suppliers.ofInstance(ref.get().getObjectId())).call(); command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call(); return true; } else if (continueRevert) { command(UpdateRef.class).setName(Ref.ORIG_HEAD) .setNewValue(currHead.get().getObjectId()).call(); } while (ret); command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call();
command(RevertAbort.class).setProgressListener(getProgressListener()).call(); return true; final Optional<Ref> head = command(RefParse.class).setName(Ref.HEAD).call(); checkState(head.isPresent(), "Repository has no HEAD, can't revert."); currHead = head.get(); checkState(!hasConflicts || abort, "Cannot run operation while merge conflicts exist."); Optional<Ref> ref = command(RefParse.class).setName(Ref.ORIG_HEAD).call(); if (continueRevert) { checkState(ref.isPresent(), command(UpdateRef.class).setName(Ref.ORIG_HEAD).setNewValue(currHead.getObjectId()) .call(); } while (ret); command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call();
if (numConflicts > 0L) { command(ConflictsWriteOp.class).setConflicts(conflicts).call();
if (!conflicts.isEmpty()) { command(ConflictsWriteOp.class).setConflicts(conflicts).call();
private void createCommit(RevCommit commit) { // write new tree ObjectId newTreeId = command(WriteTree2.class).call(); long timestamp = platform().currentTimeMillis(); String committerName = resolveCommitter(); String committerEmail = resolveCommitterEmail(); // Create new commit CommitBuilder builder = new CommitBuilder(); builder.setParentIds(Arrays.asList(revertHead)); builder.setTreeId(newTreeId); builder.setCommitterTimestamp(timestamp); builder.setMessage( "Revert '" + commit.getMessage() + "'\nThis reverts " + commit.getId().toString()); builder.setCommitter(committerName); builder.setCommitterEmail(committerEmail); builder.setAuthor(committerName); builder.setAuthorEmail(committerEmail); RevCommit newCommit = builder.build(); objectDatabase().put(newCommit); revertHead = newCommit.getId(); command(UpdateRef.class).setName(currentBranch).setNewValue(revertHead).call(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call(); workingTree().updateWorkHead(newTreeId); stagingArea().updateStageHead(newTreeId); }
private void createCommit(RevCommit commit) { // write new tree ObjectId newTreeId = command(WriteTree2.class).call(); long timestamp = platform().currentTimeMillis(); String committerName = resolveCommitter(); String committerEmail = resolveCommitterEmail(); // Create new commit RevCommitBuilder builder = RevCommit.builder(); builder.parentIds(Arrays.asList(revertHead)); builder.treeId(newTreeId); builder.committerTimestamp(timestamp); builder.message( "Revert '" + commit.getMessage() + "'\nThis reverts " + commit.getId().toString()); builder.committer(committerName); builder.committerEmail(committerEmail); builder.author(committerName); builder.authorEmail(committerEmail); RevCommit newCommit = builder.build(); objectDatabase().put(newCommit); revertHead = newCommit.getId(); command(UpdateRef.class).setName(currentBranch).setNewValue(revertHead).call(); command(UpdateSymRef.class).setName(Ref.HEAD).setNewValue(currentBranch).call(); workingTree().updateWorkHead(newTreeId); stagingArea().updateStageHead(newTreeId); }
try (AutoCloseableIterator<DiffEntry> reverseDiff = command(DiffTree.class) .setNewTree(parentTreeId).setOldTree(commit.getTreeId()).setReportTrees(false) .call()) { if (diff.isAdd()) { Optional<NodeRef> node = command(FindTreeChild.class) .setChildPath(diff.newPath()).setParent(headTree).call(); Optional<NodeRef> node = command(FindTreeChild.class) .setChildPath(diff.oldPath()).setParent(headTree).call(); ObjectId nodeId = node.get().getNode().getObjectId();