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

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


{

    protected void commit( File workingDirectory, ScmRepository repository )
        throws Exception
    {
        CheckInScmResult result = getScmManager().checkIn( repository, new ScmFileSet( workingDirectory ), "No msg" );

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

        List<ScmFile> committedFiles = result.getCheckedInFiles();

        assertEquals( "Expected 2 files in the committed files list " + committedFiles, 2, committedFiles.size() );
    }
View Full Code Here


        assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) );

        this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() );
        changeReadmeTxt( readmeTxt );

        CheckInScmResult checkinResult =
            getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "commit message" );

        assertResultIsSuccess( checkinResult );

        CheckOutScmResult checkoutResult =
View Full Code Here

{

    private void commit( File workingDirectory, ScmRepository repository )
        throws Exception
    {
        CheckInScmResult result = getScmManager().checkIn( repository, new ScmFileSet( workingDirectory ), "No msg" );

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

        List<ScmFile> committedFiles = result.getCheckedInFiles();

        assertEquals(
            "Expected 3 files in the committed files list:\n  " + StringUtils.join( committedFiles.iterator(), "\n  " ),
            3, committedFiles.size() );
    }
View Full Code Here

        // pause a couple seconds...
        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() );

        result = manager.blame( repository, fileSet, "readme.txt" );

        // pause a couple seconds...
        Thread.sleep( 2000 );
View Full Code Here

        assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) );

        this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() );
        changeReadmeTxt( readmeTxt );

        CheckInScmResult checkinResult =
            getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "commit message" );

        assertResultIsSuccess( checkinResult );

        CheckOutScmResult checkoutResult =
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

        scmRepository.getProviderRepository().setUser( username );
        AddScmResult addResult = getScmManager().add( scmRepository, new ScmFileSet( getWorkingCopy(), "**/*.java" ) );

        assertResultIsSuccess( addResult );

        CheckInScmResult result =
            getScmManager().checkIn( scmRepository, new ScmFileSet( getWorkingCopy(), "**/Foo.java" ), "Commit message" );

        assertResultIsSuccess( result );
    }
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

        if ( status != 0 || ( err.hasBeenFed() && !err.getOutput().startsWith( TFS_CHECKIN_POLICIES_ERROR ) ) )
        {
            getLogger().error( "ERROR in command: " + command.getCommandString()
                                   + "; Error code for TFS checkin command - " + status );
            return new CheckInScmResult( command.getCommandString(), "Error code for TFS checkin command - " + status,
                                         err.getOutput(), false );
        }
        return new CheckInScmResult( command.getCommandString(), fileConsumer.getFiles() );
    }
View Full Code Here

        File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null);

        try {
            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 {
            Commandline cl = null;

            if (!fileSet.getFileList().isEmpty()) {
                // If specific fileSet is given, we have to git-add them first,
                // otherwise we will use 'git-commit -a' later.
                cl       = GitAddCommand.createCommandLine(fileSet.getBasedir(), fileSet.getFileList());
                exitCode = GitCommandLineUtils.execute(cl, stdout, stderr, getLogger());
                if (exitCode != 0) {
                    return new CheckInScmResult(cl.toString(), "The git-add command failed.", stderr.getOutput(), false);
                }
            }

            // The git-commit command 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.
            GitStatusConsumer statusConsumer = new GitStatusConsumer(getLogger(), fileSet.getBasedir());

            cl       = GitStatusCommand.createCommandLine(repository, fileSet);
            exitCode = GitCommandLineUtils.execute(cl, 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)");
                }
            }

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

            cl       = createPushCommandLine(fileSet, repository, 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 (Object foo : statusConsumer.getChangedFiles()) {
                ScmFile scmfile = new ScmFile(((ScmFile) foo).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 (Iterator<?> itfl = fileSet.getFileList().iterator(); itfl.hasNext();) {
                        File f = (File) itfl.next();

                        if (f.toString().equals(scmfile.getPath())) {
                            checkedInFiles.add(scmfile);
                        }
                    }
                }
            }

            return new CheckInScmResult(cl.toString(), checkedInFiles);
        } finally {
            try {
                FileUtils.forceDelete(messageFile);
            } catch (IOException ex) {
                // ignore
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.