Package org.apache.maven.scm.command.checkin

Examples of org.apache.maven.scm.command.checkin.CheckInScmResult


            new IsEqual( PREFIX + "release-label" )};
        scmProviderMock
            .expects( new InvokeOnceMatcher() )
            .method( "checkIn" )
            .with( arguments )
            .will( new ReturnStub( new CheckInScmResult( "...", Collections.singletonList( new ScmFile( rootProject
                       .getFile().getPath(), ScmFileStatus.CHECKED_IN ) ) ) ) );

       
       
        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
View Full Code Here


            new IsEqual( PREFIX + "release-label" )};
        scmProviderMock
            .expects( new InvokeOnceMatcher() )
            .method( "checkIn" )
            .with( arguments )
            .will( new ReturnStub( new CheckInScmResult( "...", Collections.singletonList( new ScmFile( rootProject
                       .getFile().getPath(), ScmFileStatus.CHECKED_IN ) ) ) ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
View Full Code Here

            new IsEqual( "[maven-release-manager] prepare for next development iteration" )};
        scmProviderMock
            .expects( new InvokeOnceMatcher() )
            .method( "checkIn" )
            .with( arguments )
            .will( new ReturnStub( new CheckInScmResult( "...", Collections.singletonList( new ScmFile( rootProject
                       .getFile().getPath(), ScmFileStatus.CHECKED_IN ) ) ) ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
View Full Code Here

            new IsEqual( PREFIX + "release-label" )};
        scmProviderMock
            .expects( new InvokeOnceMatcher() )
            .method( "checkIn" )
            .with( arguments )
            .will( new ReturnStub( new CheckInScmResult( "...", Collections.singletonList( new ScmFile( rootProject
                       .getFile().getPath(), ScmFileStatus.CHECKED_IN ) ) ) ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
View Full Code Here

        ScmManager scmManager = (ScmManager) lookup( ScmManager.ROLE );
        ScmProviderStub providerStub = (ScmProviderStub) scmManager.getProviderByUrl(
            releaseDescriptor.getScmSourceUrl() );

        providerStub.setCheckInScmResult( new CheckInScmResult( "", "", "", false ) );

        try
        {
            phase.execute( releaseDescriptor, new DefaultReleaseEnvironment(), reactorProjects );
View Full Code Here

    private void checkin( ScmProvider provider, ScmRepository repository, ScmFileSet fileSet,
                          ReleaseDescriptor releaseDescriptor, String message )
        throws ReleaseExecutionException, ReleaseScmCommandException
    {
        CheckInScmResult result;
        try
        {
            result = provider.checkIn( repository, fileSet, (ScmVersion) null, message );
        }
        catch ( ScmException e )
        {
            throw new ReleaseExecutionException( "An error is occurred in the checkin process: " + e.getMessage(), e );
        }

        if ( !result.isSuccess() )
        {
            throw new ReleaseScmCommandException( "Unable to commit files", result );
        }
        if ( releaseDescriptor.isRemoteTagging() )
        {
            releaseDescriptor.setScmReleasedPomRevision( result.getScmRevision() );
        }
    }
View Full Code Here

            new IsEqual( message )};
        scmProviderMock
            .expects( new InvokeOnceMatcher() )
            .method( "checkIn" )
            .with( arguments )
            .will( new ReturnStub( new CheckInScmResult( "...", Collections.singletonList( new ScmFile( rootProject
                       .getFile().getPath(), ScmFileStatus.CHECKED_IN ) ) ) ) );

       
       
        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
View Full Code Here

        try
        {
            ScmRepository repository = getScmRepository();

            CheckInScmResult result = getScmManager().checkIn( repository, getFileSet(),
                                                               getScmVersion( scmVersionType, scmVersion ), message );

            checkResult( result );
        }
        catch ( IOException e )
View Full Code Here

        {
            FileUtils.fileWrite( messageFile.getAbsolutePath(), message );
        }
        catch ( IOException ex )
        {
            return new CheckInScmResult( null, "Error while making a temporary file for the commit message: "
                + ex.getMessage(), null, false );
        }

        try
        {
            if ( !fileSet.getFileList().isEmpty() )
            {
                // if specific fileSet is given, we have to git-add them first
                // otherwise we will use 'git-commit -a' later

                Commandline clAdd = GitAddCommand.createCommandLine( fileSet.getBasedir(), fileSet.getFileList() );

                exitCode = GitCommandLineUtils.execute( clAdd, stdout, stderr, getLogger() );

                if ( exitCode != 0 )
                {
                    return new CheckInScmResult( clAdd.toString(), "The git-add command failed.", stderr.getOutput(),
                                                 false );
                }

            }
           
         // SCM-709: statusCommand uses repositoryRoot instead of workingDirectory, adjust it with relativeRepositoryPath
            Commandline clRevparse = GitStatusCommand.createRevparseShowToplevelCommand( fileSet );
           
            stdout = new CommandLineUtils.StringStreamConsumer();
            stderr = new CommandLineUtils.StringStreamConsumer();

            URI relativeRepositoryPath = null;
           
            exitCode = GitCommandLineUtils.execute( clRevparse, stdout, stderr, getLogger() );
            if ( exitCode != 0 )
            {
                // git-status returns non-zero if nothing to do
                if ( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "Could not resolve toplevel" );
                }
            }
            else
            {
                relativeRepositoryPath = GitStatusConsumer.resolveURI( stdout.getOutput().trim(), fileSet.getBasedir().toURI() );
            }

            // git-commit doesn't show single files, but only summary :/
            // so we must run git-status and consume the output
            // borrow a few things from the git-status command
            Commandline clStatus = GitStatusCommand.createCommandLine( repository, fileSet );

            GitStatusConsumer statusConsumer = new GitStatusConsumer( getLogger(), fileSet.getBasedir(), relativeRepositoryPath );
            exitCode = GitCommandLineUtils.execute( clStatus, statusConsumer, stderr, getLogger() );
            if ( exitCode != 0 )
            {
                // git-status returns non-zero if nothing to do
                if ( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "nothing added to commit but untracked files present (use \"git add\" to " +
                            "track)" );
                }
            }
           
            if ( statusConsumer.getChangedFiles().isEmpty() )
            {
                return new CheckInScmResult( null, statusConsumer.getChangedFiles() );
            }

            Commandline clCommit = createCommitCommandLine( repository, fileSet, messageFile );

            exitCode = GitCommandLineUtils.execute( clCommit, stdout, stderr, getLogger() );
            if ( exitCode != 0 )
            {
                return new CheckInScmResult( clCommit.toString(), "The git-commit command failed.", stderr.getOutput(),
                                             false );
            }

            if( repo.isPushChanges() )
            {
                Commandline cl = createPushCommandLine( getLogger(), repository, fileSet, version );

                exitCode = GitCommandLineUtils.execute( cl, stdout, stderr, getLogger() );
                if ( exitCode != 0 )
                {
                    return new CheckInScmResult( cl.toString(), "The git-push command failed.", stderr.getOutput(), false );
                }               
            }

            List<ScmFile> checkedInFiles = new ArrayList<ScmFile>( statusConsumer.getChangedFiles().size() );

            // rewrite all detected files to now have status 'checked_in'
            for ( ScmFile changedFile : statusConsumer.getChangedFiles() )
            {
                ScmFile scmfile = new ScmFile( changedFile.getPath(), ScmFileStatus.CHECKED_IN );

                if ( fileSet.getFileList().isEmpty() )
                {
                    checkedInFiles.add( scmfile );
                }
                else
                {
                    // if a specific fileSet is given, we have to check if the file is really tracked
                    for ( File f : fileSet.getFileList() )
                    {
                        if ( FilenameUtils.separatorsToUnix( f.getPath() ).equals( scmfile.getPath() ) )
                        {
                            checkedInFiles.add( scmfile );
                        }

                    }
                }
            }

            return new CheckInScmResult( clCommit.toString(), checkedInFiles );
        }
        finally
        {
            try
            {
View Full Code Here

     * Convenience method to check in files to the repository
     */
    protected CheckInScmResult checkIn( File workingDirectory, ScmRepository repository )
        throws Exception
    {
        CheckInScmResult result = getScmManager().getProviderByUrl( getScmUrl() )
            .checkIn( repository, new ScmFileSet( workingDirectory ), (ScmVersion) null, "Initial Checkin" );

        assertTrue( "Check result was successful, output: " + result.getCommandOutput(), result.isSuccess() );

        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.checkin.CheckInScmResult

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.