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

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


    ScmFileSet fileSet = new ScmFileSet(scmRoot);

    // Let's commit everything !
    try {
      CheckInScmResult result = this.scmManager.checkIn(this.scmRepository, fileSet, commitMessage);
      if(!result.isSuccess()){
        LOGGER.severe("[checkinFiles] Problem during SCM commit : "+result.getCommandOutput());
        return checkinOk;
      }
      checkinOk = true;
    } catch (ScmException e) {
      LOGGER.throwing(ScmManager.class.getName(), "checkIn", 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 );
                    }

                }

                // 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() );
                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 = createSpecificPushCommandLine( 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

                    repository.getURI() };

                result = HgUtils.execute( new HgConsumer( getLogger() ), getLogger(), fileSet.getBasedir(), pushCmd );
            }

            return new CheckInScmResult( commitedFiles, result );
        }

        return new CheckInScmResult( commitedFiles, result );
    }
View Full Code Here

                {
                    iter.remove();
                }
            }
            // TODO capture the transaction id from the promote
            return new CheckInScmResult( accuRev.getCommandLines(), getScmFiles( promotedFiles,
                                                                                 ScmFileStatus.CHECKED_IN ) );
        }
        else
        {
            return new CheckInScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

        catch ( IOException ex )
        {
            throw new ScmException( "Error while checking in the files.", ex );
        }

        return new CheckInScmResult( null, checkedInFiles );
    }
View Full Code Here

        IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
        Sandbox siSandbox = iRepo.getSandbox();
        List<ScmFile> changedFiles = siSandbox.checkInUpdates( message );
        if ( siSandbox.getOverallCheckInSuccess() )
        {
            return new CheckInScmResult( "si ci/drop", changedFiles );
        }
        else
        {
            return new CheckInScmResult( changedFiles,
                                         new ScmResult( "si ci/drop", "There was a problem updating the repository", "",
                                                        false ) );
        }
    }
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

                RefSpec refSpec = new RefSpec( Constants.R_HEADS + branch + ":" + Constants.R_HEADS + branch );
                getLogger().info( "push changes to remote... " + refSpec.toString() );
                JGitUtils.push( getLogger(), git, (GitScmProviderRepository) repo, refSpec );
            }

            return new CheckInScmResult( "JGit checkin", checkedInFiles );
        }
        catch ( Exception e )
        {
            throw new ScmException( "JGit checkin failure!", 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 );
        }

        Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet, messageFile );

        SvnCheckInConsumer consumer = new SvnCheckInConsumer( getLogger(), fileSet.getBasedir() );

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

        if ( getLogger().isInfoEnabled() )
        {
            getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) );
            getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
        }

        int exitCode;

        try
        {
            exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr, getLogger() );
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Error while executing command.", ex );
        }
        finally
        {
            try
            {
                FileUtils.forceDelete( messageFile );
            }
            catch ( IOException ex )
            {
                // ignore
            }
        }

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

        return new CheckInScmResult( cl.toString(), consumer.getCheckedInFiles(),
                                     Integer.toString( consumer.getRevision() ) );
    }
View Full Code Here

        Thread.sleep( 2000 );

        //Make a change to the readme.txt and commit the change
        this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() );
        ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
        CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG );
        assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );

        ChangeLogScmResult secondResult = provider.changeLog( getScmRepository(), fileSet, (ScmVersion) null, null );
        assertTrue( secondResult.getProviderMessage(), secondResult.isSuccess() );
        assertEquals( firstLogSize + 1, secondResult.getChangeLog().getChangeSets().size() );
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.