Package org.apache.maven.scm.command.add

Examples of org.apache.maven.scm.command.add.AddScmResult


        try
        {
            ScmRepository repository = getScmRepository();

            AddScmResult result = getScmManager().add( repository, getFileSet() );

            checkResult( result );

            getLog().info( "" + result.getAddedFiles().size() + " files successfully added." );

        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Cannot run add command : ", e );
View Full Code Here


        List<ScmFile> scmFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
        for (File f : fileSet.getFileList())
        {
            scmFiles.add( new ScmFile( f.getPath(), ScmFileStatus.ADDED ) );
        }
        return new AddScmResult( "", scmFiles );
    }
View Full Code Here

        File f = new File( workingDirectory.getAbsolutePath() + File.separator + "pom.xml" );
        FileUtils.fileWrite( f.getAbsolutePath(), "toto" );

        ScmFileSet scmFileSet = new ScmFileSet( workingDirectory, new File( "pom.xml" ) );
        AddScmResult addResult = getScmManager().add( scmRepository, scmFileSet );
        assertResultIsSuccess( addResult );

        CheckInScmResult checkInScmResult = getScmManager().checkIn( scmRepository, scmFileSet, "commit" );
        assertResultIsSuccess( checkInScmResult );
        assertEquals( 1, checkInScmResult.getCheckedInFiles().size() );
View Full Code Here

        File workingDir = fileSet.getBasedir();
        HgAddConsumer consumer = new HgAddConsumer( getLogger(), workingDir );
        ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, addCmd );

        AddScmResult addScmResult = new AddScmResult( consumer.getAddedFiles(), result );

        // add in bogus 'added' results for empty directories.  only need to do this because the maven scm unit test
        // framework seems to think that this is the way we should behave.  it's pretty hacky. -rwd
        for ( File workingFile : fileSet.getFileList() )
        {
            File file = new File( workingDir + "/" + workingFile.getPath() );
            if ( file.isDirectory() && file.listFiles().length == 0 )
            {
                addScmResult.getAddedFiles().add( new ScmFile( workingFile.getPath(), ScmFileStatus.ADDED ) );
            }
        }

        return addScmResult;
    }
View Full Code Here

     * Create a new ScmProviderStub with bogus (not null) attributes
     */
    public ScmProviderStub()
    {
        setScmSpecificFilename( "" );
        setAddScmResult( new AddScmResult( "", Collections.<ScmFile>emptyList() ) );
        setBranchScmResult( new BranchScmResult( "", Collections.<ScmFile>emptyList() ) );
        setChangeLogScmResult( new ChangeLogScmResult( "", "", "", true ) );
        setCheckInScmResult( new CheckInScmResult( "", "", "", true ) );
        setCheckOutScmResult( new CheckOutScmResult( "", "", "", true ) );
        setDiffScmResult( new DiffScmResult( "", "", "", true ) );
View Full Code Here

        File workingDir = fileSet.getBasedir();
        BazaarAddConsumer consumer = new BazaarAddConsumer( getLogger(), workingDir );
        ScmResult result = BazaarUtils.execute( consumer, getLogger(), workingDir, addCmd );

        return new AddScmResult( consumer.getAddedFiles(), result );
    }
View Full Code Here

                                                              getLogger() );

            // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses?
            if ( !isSuccess )
            {
                return new AddScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(),
                                         false );
            }

            return new AddScmResult( cl.toString(), addedFiles );
        }
        catch ( Exception e )
        {
            e.printStackTrace();
            return new AddScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(),
                                     false );
        }
    }
View Full Code Here

            localRepo.addFile( path );
            fileList.add( new ScmFile( path, ScmFileStatus.ADDED ) );
        }

        // TODO: Also, ensure it is tested from the update test
        return new AddScmResult( null, fileList );
    }
View Full Code Here

            if ( repo.isFileAdded( path ) )
            {
                return new MkdirScmResult( null, "Directory already exists!", "Directory already exists.", false );
            }

            AddScmResult result = (AddScmResult) addCmd.execute( repository, fileSet, parameters );
            createdDirs.addAll( result.getAddedFiles() );
        }

        return new MkdirScmResult( null, createdDirs );
    }
View Full Code Here

        int exitCode;

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

        // git-add 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)" );
            }
        }

        List<ScmFile> changedFiles = new ArrayList<ScmFile>();

        // rewrite all detected files to now have status 'checked_in'
        for ( ScmFile scmfile : statusConsumer.getChangedFiles() )
        {
            // if a specific fileSet is given, we have to check if the file is really tracked
            for ( File f : fileSet.getFileList() )
            {
                if ( f.toString().equals( scmfile.getPath() ) )
                {
                    changedFiles.add( scmfile );
                }
            }
        }
        return new AddScmResult( cl.toString(), changedFiles );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.add.AddScmResult

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.