Search in sources :

Example 6 with BlameLine

use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.

the class TfsBlameConsumer method consumeLine.

public void consumeLine(String line) {
    Matcher matcher = LINE_PATTERN.matcher(line);
    if (matcher.find()) {
        String revision = matcher.group(1).trim();
        String author = matcher.group(2).trim();
        String dateStr = matcher.group(3).trim();
        Date date = parseDate(dateStr, null, TFS_TIMESTAMP_PATTERN);
        lines.add(new BlameLine(date, revision, author));
    }
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine) Matcher(java.util.regex.Matcher) Date(java.util.Date)

Example 7 with BlameLine

use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.

the class TfsBlameConsumerTest method testConsumer.

public void testConsumer() throws Exception {
    File testFile = getTestFile("src/test/resources/tfs/annotatelog.txt");
    TfsBlameConsumer consumer = new TfsBlameConsumer(new DefaultLog());
    FileInputStream fis = new FileInputStream(testFile);
    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
    String s = in.readLine();
    while (s != null) {
        consumer.consumeLine(s);
        s = in.readLine();
    }
    Assert.assertEquals(3, consumer.getLines().size());
    BlameLine line1 = (BlameLine) consumer.getLines().get(0);
    Assert.assertEquals("3", line1.getRevision());
    Assert.assertEquals("hatusr01", line1.getAuthor());
    BlameLine line2 = (BlameLine) consumer.getLines().get(1);
    Assert.assertEquals("4", line2.getRevision());
    Assert.assertEquals("buckh", line2.getAuthor());
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine) InputStreamReader(java.io.InputStreamReader) DefaultLog(org.apache.maven.scm.log.DefaultLog) BufferedReader(java.io.BufferedReader) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 8 with BlameLine

use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.

the class JazzBlameConsumer method consumeLine.

/**
 * Process one line of output from the execution of the "scm annotate" command.
 *
 * @param line The line of output from the external command that has been pumped to us.
 * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
 */
public void consumeLine(String line) {
    super.consumeLine(line);
    Matcher matcher = LINE_PATTERN.matcher(line);
    if (matcher.matches()) {
        String lineNumberStr = matcher.group(1);
        String owner = matcher.group(2);
        String changeSetNumberStr = matcher.group(3);
        String dateStr = matcher.group(4);
        Date date = parseDate(dateStr, JAZZ_TIMESTAMP_PATTERN, null);
        fLines.add(new BlameLine(date, changeSetNumberStr, owner));
    }
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine) Matcher(java.util.regex.Matcher) Date(java.util.Date)

Example 9 with BlameLine

use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.

the class JazzBlameCommandTckTest method verifyResult.

/**
 * {@inheritDoc}
 *
 * @see org.apache.maven.scm.tck.command.blame.BlameCommandTckTest#verifyResult(org.apache.maven.scm.command.blame.BlameScmResult)
 */
@Override
protected void verifyResult(BlameScmResult result) {
    List<BlameLine> lines = result.getLines();
    assertEquals("Expected 1 line in blame!", 1, lines.size());
    BlameLine line = lines.get(0);
    assertNotSame("The revision can not be zero!", "0", line.getRevision());
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine)

Example 10 with BlameLine

use of org.apache.maven.scm.command.blame.BlameLine in project maven-scm by apache.

the class SvnBlameCommandTckTest method verifyResult.

protected void verifyResult(BlameScmResult result) {
    List<BlameLine> lines = result.getLines();
    assertEquals("Expected 1 line in blame", 1, lines.size());
    BlameLine line = lines.get(0);
    assertEquals("trygvis", line.getAuthor());
    assertEquals("7", line.getRevision());
}
Also used : BlameLine(org.apache.maven.scm.command.blame.BlameLine)

Aggregations

BlameLine (org.apache.maven.scm.command.blame.BlameLine)29 Date (java.util.Date)11 Matcher (java.util.regex.Matcher)7 File (java.io.File)5 BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)5 DefaultLog (org.apache.maven.scm.log.DefaultLog)4 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 ScmException (org.apache.maven.scm.ScmException)2 ScmFileSet (org.apache.maven.scm.ScmFileSet)2 Test (org.junit.Test)2 FileInputStream (java.io.FileInputStream)1 FileReader (java.io.FileReader)1 InputStream (java.io.InputStream)1 DateFormat (java.text.DateFormat)1 CommandParameters (org.apache.maven.scm.CommandParameters)1 BlameScmRequest (org.apache.maven.scm.command.blame.BlameScmRequest)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1