/** * Runs the command and builds the appropriate response * * @param context - the context to use for this command * * @throws CommandSpecException */ @Override protected void runInternal(CommandContext context) { final Context geogig = this.getRepositoryContext(context); AddOp command = geogig.command(AddOp.class); if (path != null) { command.addPattern(path); } command.call(); context.setResponseContent(new CommandResponse() { @Override public void write(ResponseWriter out) throws Exception { out.start(); out.writeElement("Add", "Success"); out.finish(); } }); }
AddOp op = geogig.command(AddOp.class); if (patterns.size() == 1) { op.addPattern(patterns.get(0)); WorkingTree workTree = op.setUpdateOnly(updateOnly) .setProgressListener(cli.getProgressListener()).call();
final StagingArea index = stagingArea(); try (AutoCloseableIterator<DiffEntry> staged = index.getStaged(null)) { if (null == pathFilter && !staged.hasNext() && !updateOnly && index.countConflicted(null) == 0) { progress.started(); Optional<ObjectId> workHead = command(RevParse.class).setRefSpec(Ref.WORK_HEAD) .call(); if (workHead.isPresent()) { command(UpdateRef.class).setName(Ref.STAGE_HEAD).setNewValue(workHead.get()) .call(); final long numChanges = workingTree().countUnstaged(pathFilter).count(); try (AutoCloseableIterator<DiffEntry> sourceIterator = workingTree() .getUnstaged(pathFilter)) { Iterator<DiffEntry> updatedIterator = sourceIterator; ConflictsDatabase conflictsDatabase = conflictsDatabase(); conflictsDatabase.removeByPrefix(null, pathFilter);
private WorkingTree callAdd() { final AddOp addOp = context.command(AddOp.class); addOp.setProgressListener(getProgressListener()); return addOp.call(); }
public void add() { repo.command(AddOp.class).call(); }
@Test public void testAddEmptyTree() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); workingTree.createTypeTree(pointsName, pointsType); geogig.command(AddOp.class).setUpdateOnly(false).call(); assertTrue(index.findStaged(pointsName).isPresent()); } }
@Test public void testAddUpdateWithPathFilter() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); insert(points1_modified); insert(lines1); // stage only Lines changed geogig.command(AddOp.class).setUpdateOnly(true).addPattern(pointsName).call(); List<DiffEntry> staged = toList(repo.index().getStaged(null)); assertEquals(2, staged.size()); assertEquals(pointsName, staged.get(0).newName()); assertEquals(idP1, staged.get(1).newName()); List<DiffEntry> unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); geogig.command(AddOp.class).setUpdateOnly(true).addPattern("Points").call(); unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); }
if (mapping != null || filter != null) { progressListener.setDescription("Staging features..."); command(AddOp.class).setProgressListener(progressListener).call(); progressListener.setDescription("Committing features..."); command(CommitOp.class).setMessage(message)
protected void add(Repository repo) { repo.command(AddOp.class).call(); }
@Test public void testAddEmptyTree() throws Exception { WorkingTree workingTree = geogig.getRepository().workingTree(); workingTree.createTypeTree(pointsName, pointsType); geogig.command(AddOp.class).setUpdateOnly(false).call(); assertTrue(index.findStaged(pointsName).isPresent()); } }
@Test public void testAddUpdateWithPathFilter() throws Exception { insertAndAdd(points1); geogig.command(CommitOp.class).call(); insert(points1_modified); insert(lines1); // stage only Lines changed geogig.command(AddOp.class).setUpdateOnly(true).addPattern(pointsName).call(); List<DiffEntry> staged = toList(repo.index().getStaged(null)); assertEquals(2, staged.size()); assertEquals(pointsName, staged.get(0).newName()); assertEquals(idP1, staged.get(1).newName()); List<DiffEntry> unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); geogig.command(AddOp.class).setUpdateOnly(true).addPattern("Points").call(); unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(idL1, unstaged.get(1).newName()); }
private WorkingTree callAdd() { final AddOp addOp = context.command(AddOp.class); addOp.setProgressListener(getProgressListener()); return addOp.call(); }
@Test public void testNothingToCommit() throws Exception { geogig.command(AddOp.class).addPattern(".").call(); exception.expect(NothingToCommitException.class); geogig.command(CommitOp.class).call(); }
public void add() { repo.command(AddOp.class).call(); }
AddOp op = geogig.command(AddOp.class); if (patterns.size() == 1) { op.addPattern(patterns.get(0)); WorkingTree workTree = op.setUpdateOnly(updateOnly) .setProgressListener(cli.getProgressListener()).call();
@Test public void testAddUpdate() throws Exception { insert(points1); geogig.command(AddOp.class).call(); geogig.command(CommitOp.class).call(); insert(points1_modified); insert(lines1); geogig.command(AddOp.class).setUpdateOnly(true).call(); List<DiffEntry> unstaged = toList(repo.workingTree().getUnstaged(null)); assertEquals(2, unstaged.size()); assertEquals(linesName, unstaged.get(0).newName()); assertEquals(lines1.getIdentifier().getID(), unstaged.get(1).newName()); }
private WorkingTree callAdd() { final AddOp addOp = context.command(AddOp.class); addOp.setProgressListener(getProgressListener()); return addOp.call(); }
final StagingArea index = stagingArea(); try (AutoCloseableIterator<DiffEntry> staged = index.getStaged(null)) { if (null == pathFilter && !staged.hasNext() && !updateOnly && index.countConflicted(null) == 0) { progress.started(); Optional<ObjectId> workHead = command(RevParse.class).setRefSpec(Ref.WORK_HEAD) .call(); if (workHead.isPresent()) { command(UpdateRef.class).setName(Ref.STAGE_HEAD).setNewValue(workHead.get()) .call(); final long numChanges = workingTree().countUnstaged(pathFilter).count(); try (AutoCloseableIterator<DiffEntry> sourceIterator = workingTree() .getUnstaged(pathFilter)) { Iterator<DiffEntry> updatedIterator = sourceIterator; ConflictsDatabase conflictsDatabase = conflictsDatabase(); conflictsDatabase.removeByPrefix(null, pathFilter);
@Test public void testNothingToCommit() throws Exception { geogig.command(AddOp.class).addPattern(".").call(); exception.expect(NothingToCommitException.class); geogig.command(CommitOp.class).call(); }
protected void add(Repository repo) { repo.command(AddOp.class).call(); }