Package org.locationtech.geogig.repository

Examples of org.locationtech.geogig.repository.Repository


    public void testCreateNewRepo() throws Exception {
        when(injector.repository()).thenReturn(mockRepo);
        Optional<Ref> absent = Optional.absent();
        when(mockRefParse.call()).thenReturn(absent);

        Repository created = init.call();
        assertSame(mockRepo, created);
        assertTrue(new File(workingDir, ".geogig").exists());
        assertTrue(new File(workingDir, ".geogig").isDirectory());

        verify(injector, times(1)).repository();
View Full Code Here


    public void testReinitializeExistingRepo() throws Exception {
        when(injector.repository()).thenReturn(mockRepo);
        Optional<Ref> absent = Optional.absent();
        when(mockRefParse.call()).thenReturn(absent);

        Repository created = init.call();

        assertSame(mockRepo, created);
        verify(mockUpdateRef, times(3)).call();
        verify(mockUpdateSymRef, times(1)).call();
View Full Code Here

     *
     * @return RevCommit the new commit with the changes from the cherry-picked commit
     */
    @Override
    protected  RevCommit _call() {
        final Repository repository = repository();
        final Optional<Ref> currHead = command(RefParse.class).setName(Ref.HEAD).call();
        Preconditions
                .checkState(currHead.isPresent(), "Repository has no HEAD, can't cherry pick.");
        Preconditions.checkState(currHead.get() instanceof SymRef,
                "Can't cherry pick from detached HEAD");
        final SymRef headRef = (SymRef) currHead.get();

        Preconditions.checkState(index().isClean() && workingTree().isClean(),
                "You must have a clean working tree and index to perform a cherry pick.");

        getProgressListener().started();

        Preconditions.checkArgument(repository.commitExists(commit),
                "Commit could not be resolved: %s.", commit);
        RevCommit commitToApply = repository.getCommit(commit);

        ObjectId headId = headRef.getObjectId();

        ObjectId parentCommitId = ObjectId.NULL;
        if (commitToApply.getParentIds().size() > 0) {
            parentCommitId = commitToApply.getParentIds().get(0);
        }
        ObjectId parentTreeId = ObjectId.NULL;
        if (repository.commitExists(parentCommitId)) {
            parentTreeId = repository.getCommit(parentCommitId).getTreeId();
        }
        // get changes
        Iterator<DiffEntry> diff = command(DiffTree.class).setOldTree(parentTreeId)
                .setNewTree(commitToApply.getTreeId()).setReportTrees(true).call();

        // see if there are conflicts
        MergeScenarioReport report = command(ReportCommitConflictsOp.class)
                .setCommit(commitToApply).call();
        if (report.getConflicts().isEmpty()) {
            // stage changes
            index().stage(getProgressListener(), diff, 0);
            // write new tree
            ObjectId newTreeId = command(WriteTree2.class).call();
            RevCommit newCommit = command(CommitOp.class).setCommit(commitToApply).call();

            repository.workingTree().updateWorkHead(newTreeId);
            repository.index().updateStageHead(newTreeId);

            getProgressListener().complete();

            return newCommit;
        } else {
View Full Code Here

     */
    @Override
    protected Void _call() {
        Preconditions.checkArgument(repositoryURL != null && !repositoryURL.isEmpty(),
                "No repository specified to clone from.");
        Repository repository = repository();
        if (repository.isSparse()) {
            Preconditions
                    .checkArgument(branch.isPresent(), "No branch specified for sparse clone.");
        }

        ProgressListener progressListener = getProgressListener();
        progressListener.started();

        // Set up origin
        Remote remote = command(RemoteAddOp.class).setName("origin").setURL(repositoryURL)
                .setMapped(repository.isSparse()).setUserName(username).setPassword(password)
                .setBranch(repository.isSparse() ? branch.get() : null).call();

        if (!depth.isPresent()) {
            // See if we are cloning a shallow clone. If so, a depth must be specified.
            Optional<IRemoteRepo> remoteRepo = RemoteUtils.newRemote(
                    GlobalContextBuilder.builder.build(Hints.readOnly()), remote, repository,
                    repository.deduplicationService());

            Preconditions.checkState(remoteRepo.isPresent(), "Failed to connect to the remote.");
            IRemoteRepo remoteRepoInstance = remoteRepo.get();
            try {
                remoteRepoInstance.open();
View Full Code Here

            } else {
                targetDirectory = currDir;
            }
        }
        final boolean repoExisted;
        final Repository repository;
        {
            GeoGIG geogig = cli.getGeogig();
            if (geogig == null) {
                Context geogigInjector = cli.getGeogigInjector();
                geogig = new GeoGIG(geogigInjector);
            }
            repoExisted = determineIfRepoExists(targetDirectory, geogig);
            final Map<String, String> suppliedConfiguration = splitConfig(config);

            try {
                repository = geogig.command(InitOp.class).setConfig(suppliedConfiguration)
                        .setTarget(targetDirectory).call();
            } catch (IllegalArgumentException e) {
                throw new CommandFailedException(e.getMessage(), e);
            } finally {
                geogig.close();
            }
        }

        File repoDirectory;
        try {
            repoDirectory = new File(repository.getLocation().toURI());
        } catch (URISyntaxException e) {
            throw new CommandFailedException("Environment home can't be resolved to a directory", e);
        }
        String message;
        if (repoExisted) {
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.repository.Repository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.