Package org.apache.maven.scm.command.blame

Examples of org.apache.maven.scm.command.blame.BlameScmResult


        ScmRepository repository = getScmRepository();
        ScmManager manager = getScmManager();
        ScmProvider provider = manager.getProviderByRepository( getScmRepository() );
        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );

        BlameScmResult result;
        BlameLine line;

        // === readme.txt ===
        result = manager.blame( repository, fileSet, "readme.txt" );
        assertNotNull( "The command returned a null result.", result );
        assertResultIsSuccess( result );
        assertEquals( "Expected 1 line in blame", 1, result.getLines().size() );
        line = (BlameLine) result.getLines().get( 0 );
        String initialRevision = line.getRevision();

        //Make a timestamp that we know are after initial revision but before the second
        Date timeBeforeSecond = new Date(); // Current time
        // pause a couple seconds...
        Thread.sleep( 2000 );
        //Make a change to the readme.txt and commit the change
        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 );
        Date timeAfterSecond = new Date(); // Current time

        assertNotNull( "The command returned a null result.", result );
        assertResultIsSuccess( result );

        assertEquals( "Expected 1 line in blame", 1, result.getLines().size() );
        line = (BlameLine) result.getLines().get( 0 );

        assertNotNull( "Expected not null author", line.getAuthor() );
        assertNotNull( "Expected not null revision", line.getRevision() );
        assertNotNull( "Expected not null date", line.getDate() );
View Full Code Here


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

        int exitCode = GitCommandLineUtils.execute( cl, consumer, stderr, getLogger() );
        if ( exitCode != 0 )
        {
            return new BlameScmResult( cl.toString(), "The git blame command failed.", stderr.getOutput(), false );
        }
        return new BlameScmResult( cl.toString(), consumer.getLines() );
    }
View Full Code Here

        {
            throw new ScmException( "Error while executing command.", ex );
        }
        if ( exitCode != 0 )
        {
            return new BlameScmResult( cl.toString(), "The perforce command failed.", stderr.getOutput(), false );
        }

        // Call filelog command

        cl = createFilelogCommandLine( (PerforceScmProviderRepository) repo, workingDirectory.getBasedir(), filename );

        PerforceFilelogConsumer filelogConsumer = new PerforceFilelogConsumer( getLogger() );

        try
        {
            exitCode = CommandLineUtils.executeCommandLine( cl, filelogConsumer, stderr );
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Error while executing command.", ex );
        }
        if ( exitCode != 0 )
        {
            return new BlameScmResult( cl.toString(), "The perforce command failed.", stderr.getOutput(), false );
        }

        // Combine results

        List<BlameLine> lines = blameConsumer.getLines();
        for ( int i = 0; i < lines.size(); i++ )
        {
            BlameLine line = lines.get( i );
            String revision = line.getRevision();
            line.setAuthor( filelogConsumer.getAuthor( revision ) );
            line.setDate( filelogConsumer.getDate( revision ) );
        }

        return new BlameScmResult( cl.toString(), lines );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.blame.BlameScmResult

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.