Examples of InfoScmResult


Examples of org.apache.maven.scm.command.info.InfoScmResult

    {
        // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without
        // a basedir (which isn't used here anyway), so use a dummy file.
        SvnInfoCommand infoCmd = (SvnInfoCommand) getInfoCommand();
        infoCmd.setLogger( this.getLogger() );
        InfoScmResult result =
            infoCmd.executeInfoCommand( null, new ScmFileSet( new File( "" ), path ), null, false, null );

        if ( result.getInfoItems().size() != 1 )
        {
            throw new ScmRepositoryException(
                "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" )
                    + " items returned by the info command" );
        }

        return result.getInfoItems().get( 0 ).getURL();
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

        if ( checkWorkingDirectoryUrl() )
        {
            getLogger().debug( "Checking svn info 'URL:' field matches current sources directory" );
            try
            {
                InfoScmResult info =
                    info( result.repository, new ScmFileSet( new File( "." ) ), new CommandParameters() );
                String url = findUrlInfoItem( info );
                if ( url != null && !url.equals( scmSpecificUrl ) )
                {
                    result.messages.add( "The scm url does not match the value returned by svn info" );
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

        Commandline cli = createCommandLine( repository, fileSet, parameters );

        int exitCode = GitCommandLineUtils.execute( cli, consumer, stderr, getLogger() );
        if ( exitCode != 0 )
        {
            return new InfoScmResult( cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false );
        }
        return new InfoScmResult( cli.toString(), consumer.getInfoItems() );
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

    }

    public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
        throws ScmException
    {
        return new InfoScmResult( "", "", "", true );
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

    }

    public Map<String, String> getInfo(MavenProject project) {
        File basedir = project.getBasedir();

        InfoScmResult result = null;

        ScmLogger logger = new DefaultLog();

        GitCommand command = new GitExeScmProvider().getInfoCommand();
        command.setLogger(logger);
        try {
            ScmProviderRepository repository = new GitScmProviderRepository(basedir.getAbsolutePath());
            ScmFileSet fileSet = new ScmFileSet(basedir);
            CommandParameters parameters = new CommandParameters();
            result = (InfoScmResult) command.execute(repository, fileSet, parameters);
        } catch (ScmException e) {
            if (logger.isErrorEnabled()) {
                logger.error(e.getMessage());
            }
        }

        Map<String, String> info = new LinkedHashMap<String, String>();
        if (result != null) {
            if (result.isSuccess()) {
                List<InfoItem> items = result.getInfoItems();
                if ((items != null) && (items.size() == 1)) {
                    info.put("git.revision", items.get(0).getRevision());
                    info.put("git.author", items.get(0).getLastChangedAuthor());
                    info.put("git.repository", items.get(0).getRepositoryUUID());
                    info.put("git.date", items.get(0).getLastChangedDate());
                } else {
                    info.put("git.error", "The command returned incorrect number of arguments");
                }
            } else {
                info.put("git.error", result.getProviderMessage());
            }

        }
        return info;
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

    {
        GitScmTestUtils.initRepo( "src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy() );
        ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
        ScmProviderRepository repository = provider.makeProviderScmRepository( getRepositoryRoot() );
        assertNotNull( repository );
        InfoScmResult result = provider.info( repository, new ScmFileSet( getRepositoryRoot() ), new CommandParameters() );
        assertNotNull( result );
        assertEquals( "cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767", result.getInfoItems().get( 0 ).getRevision() );
        //
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

            throw new ScmException( "Error while executing command.", ex );
        }

        if ( exitCode != 0 )
        {
            return new InfoScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false );
        }

        return new InfoScmResult( cl.toString(), consumer.getInfoItems() );
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

    }

    public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
        throws ScmException
    {
        return new InfoScmResult( "", "", "", true );
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

    protected String getRepositoryURL( File path )
        throws ScmException
    {
        // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without
        // a basedir (which isn't used here anyway), so use a dummy file.
        InfoScmResult result = info( null, new ScmFileSet( new File( "" ), path ), null );

        if ( result.getInfoItems().size() != 1 )
        {
            throw new ScmRepositoryException(
                "Cannot find URL: " + ( result.getInfoItems().size() == 0 ? "no" : "multiple" )
                    + " items returned by the info command" );
        }

        return result.getInfoItems().get( 0 ).getURL();
    }
View Full Code Here

Examples of org.apache.maven.scm.command.info.InfoScmResult

        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        int exitCode = GitCommandLineUtils.execute( cli, consumer, stderr, getLogger() );
        if ( exitCode != 0 )
        {
            return new InfoScmResult(cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false);
        }
        return new InfoScmResult( cli.toString(), consumer.getInfoItems() );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.