maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1053421 - in /maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src: main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/ test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/ te...
Date Tue, 28 Dec 2010 20:13:15 GMT
Author: olamy
Date: Tue Dec 28 20:13:15 2010
New Revision: 1053421

URL: http://svn.apache.org/viewvc?rev=1053421&view=rev
Log:
[SCM-592] Error parsing blame for git
Submitted by Evgeny Mandrikov.

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/resources/git/blame/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/resources/git/blame/git-blame.out
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java?rev=1053421&r1=1053420&r2=1053421&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameCommand.java
Tue Dec 28 20:13:15 2010
@@ -62,6 +62,7 @@ public class GitBlameCommand
     {
         Commandline cl = GitCommandLineUtils.getBaseGitCommandLine( workingDirectory, "blame"
);
         cl.createArg().setValue( "-c" );
+        cl.createArg().setValue( "-l" );
         cl.createArg().setValue( filename );
         return cl;
     }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java?rev=1053421&r1=1053420&r2=1053421&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumer.java
Tue Dec 28 20:13:15 2010
@@ -22,7 +22,6 @@ package org.apache.maven.scm.provider.gi
 import org.apache.maven.scm.command.blame.BlameLine;
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.util.AbstractConsumer;
-import org.apache.regexp.RE;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -37,37 +36,26 @@ public class GitBlameConsumer
 {
     private static final String GIT_TIMESTAMP_PATTERN = "yyyy-MM-dd HH:mm:ss Z";
 
-    private static final String LINE_PATTERN = "(.*)\t\\((.*)\t(.*)\t.*\\)";
-
-    /**
-     * @see #LINE_PATTERN
-     */
-    private RE lineRegexp;
-
     private List lines = new ArrayList();
 
     public GitBlameConsumer( ScmLogger logger )
     {
         super( logger );
-
-        lineRegexp = new RE( LINE_PATTERN );
     }
 
     public void consumeLine( String line )
     {
-        if ( lineRegexp.match( line ) )
+        String parts[] = line.split( "\t", 4 );
+        String revision = parts[0];
+        String author = parts[1].substring( 1 );
+        String dateTimeStr = parts[2];
+
+        Date dateTime = parseDate( dateTimeStr, null, GIT_TIMESTAMP_PATTERN );
+        getLines().add( new BlameLine( dateTime, revision, author ) );
+
+        if ( getLogger().isDebugEnabled() )
         {
-            String revision = lineRegexp.getParen( 1 );
-            String author = lineRegexp.getParen( 2 );
-            String dateTimeStr = lineRegexp.getParen( 3 );
-
-            Date dateTime = parseDate( dateTimeStr, null, GIT_TIMESTAMP_PATTERN );
-            getLines().add( new BlameLine( dateTime, revision, author ) );
-
-            if ( getLogger().isDebugEnabled() )
-            {
-                getLogger().debug( author + " " + dateTimeStr );
-            }
+            getLogger().debug( author + " " + dateTimeStr );
         }
     }
 

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java?rev=1053421&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java
Tue Dec 28 20:13:15 2010
@@ -0,0 +1,42 @@
+package org.apache.maven.scm.provider.git.gitexe.command.blame;
+
+import junit.framework.Assert;
+import org.apache.maven.scm.command.blame.BlameLine;
+import org.apache.maven.scm.log.DefaultLog;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
+public class GitBlameConsumerTest
+    extends PlexusTestCase
+{
+    public void testConsumer()
+        throws Exception
+    {
+        GitBlameConsumer consumer = new GitBlameConsumer( new DefaultLog() );
+
+        File f = getTestFile( "/src/test/resources/git/blame/git-blame.out" );
+
+        BufferedReader r = new BufferedReader( new FileReader( f ) );
+
+        String line;
+
+        while ( ( line = r.readLine() ) != null )
+        {
+            consumer.consumeLine( line );
+        }
+
+        Assert.assertEquals( 73, consumer.getLines().size() );
+
+        BlameLine blameLine1 = (BlameLine) consumer.getLines().get( 11 );
+        Assert.assertEquals( "96cfe5d4", blameLine1.getRevision() );
+        Assert.assertEquals( "Tiago Bello Torres", blameLine1.getAuthor() );
+
+        BlameLine blameLine2 = (BlameLine) consumer.getLines().get( 35 );
+        Assert.assertEquals( "8748a722", blameLine2.getRevision() );
+        Assert.assertEquals( "Tiago Bello Torres", blameLine2.getAuthor() );
+
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/java/org/apache/maven/scm/provider/git/gitexe/command/blame/GitBlameConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/resources/git/blame/git-blame.out
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/resources/git/blame/git-blame.out?rev=1053421&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/resources/git/blame/git-blame.out
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/test/resources/git/blame/git-blame.out
Tue Dec 28 20:13:15 2010
@@ -0,0 +1,73 @@
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	1)/*                             
        
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	2) * Copyright (c) 1999-2009 Touch
Tecnologia e Informatica Ltda.
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	3) * Gomes de Carvalho, 1666, 3o.
Andar, Vila Olimpia, Sao Paulo, SP, Brasil.
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	4) * Todos os direitos reservados.
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	5) *                             

+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	6) * Este software e confidencial
e de propriedade da Touch Tecnologia e 
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	7) * Informatica Ltda. (Informacao
Confidencial). As informacoes contidas neste
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	8) * arquivo nao podem ser publicadas,
e seu uso esta limitado de acordo com os 
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	9) * termos do contrato de licenca.
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	10) */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	11)
+96cfe5d4	(Tiago Bello Torres	2010-06-24 14:21:29 -0300	12)package br.com.touchtec.veris.service;
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	13)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	14)import br.com.touchtec.exception.TouchException;
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	15)import br.com.touchtec.message.Message;
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	16)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	17)/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	18) * 
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	19) * 
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	20) * @author jorge
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	21) * @since
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	22) * 
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	23) */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	24)public class VerisUserAuthenticationException
extends TouchException {
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	25)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	26)	/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	27)	 * 
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	28)	 */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	29)	private static final long serialVersionUID
= 1L;
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	30)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	31)	/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	32)	 * @param message
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	33)	 * @since
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	34)	 */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	35)	public VerisUserAuthenticationException(String
message) {
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	36)		super(message);
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	37)	}
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	38)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	39)	/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	40)	 * @param cause
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	41)	 * @since
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	42)	 */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	43)	public VerisUserAuthenticationException(Throwable
cause) {
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	44)		super(cause);
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	45)	}
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	46)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	47)	/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	48)	 * @param msg
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	49)	 * @since
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	50)	 */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	51)	public VerisUserAuthenticationException(Message
msg) {
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	52)		super(msg);
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	53)	}
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	54)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	55)	/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	56)	 * @param message
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	57)	 * @param cause
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	58)	 * @since
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	59)	 */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	60)	public VerisUserAuthenticationException(String
message, Throwable cause) {
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	61)		super(message, cause);
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	62)	}
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	63)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	64)	/**
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	65)	 * @param msg
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	66)	 * @param cause
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	67)	 * @since
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	68)	 */
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	69)	public VerisUserAuthenticationException(Message
msg, Throwable cause) {
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	70)		super(msg, cause);
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	71)	}
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	72)
+8748a722	(Tiago Bello Torres	2010-06-03 17:59:00 -0300	73)}



Mime
View raw message