continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1044989 - in /continuum/trunk: continuum-base/continuum-scm/ continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/ continuum-buildagent/continuum-buildagen...
Date Mon, 13 Dec 2010 01:00:36 GMT
Author: ctan
Date: Mon Dec 13 01:00:36 2010
New Revision: 1044989

URL: http://svn.apache.org/viewvc?rev=1044989&view=rev
Log:
[CONTINUUM-2571] fixed error in change log
- set the LatestUpdateDate in the scm config used by changelog
- use the latestUpdateDate if scmVersion is empty to avoid getting error in change log

Added:
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
Modified:
    continuum/trunk/continuum-base/continuum-scm/pom.xml
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ChangeLogProjectAction.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java

Modified: continuum/trunk/continuum-base/continuum-scm/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/pom.xml?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/pom.xml (original)
+++ continuum/trunk/continuum-base/continuum-scm/pom.xml Mon Dec 13 01:00:36 2010
@@ -84,5 +84,30 @@ under the License.
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-junit3</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hamcrest</groupId>
+      <artifactId>hamcrest-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.objenesis</groupId>
+      <artifactId>objenesis</artifactId>  
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java
(original)
+++ continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/DefaultContinuumScm.java
Mon Dec 13 01:00:36 2010
@@ -21,6 +21,8 @@ package org.apache.continuum.scm;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Calendar;
+import java.util.Date;
 
 import javax.annotation.Resource;
 
@@ -144,6 +146,7 @@ public class DefaultContinuumScm
         throws ScmException
     {
         ScmVersion scmVersion = getScmVersion( configuration );
+        Date startDate = null;
 
         // TODO: probably need to base this from a working directory in the main configuration
         File workingDirectory = configuration.getWorkingDirectory();
@@ -154,7 +157,17 @@ public class DefaultContinuumScm
 
         ScmFileSet fileSet = new ScmFileSet( workingDirectory );
 
-        result = scmManager.changeLog( repository, fileSet, scmVersion, scmVersion );
+        if ( scmVersion == null || StringUtils.isBlank( scmVersion.getName() ) )
+        {
+            // let's get the start date instead
+            startDate = getScmStartDate( configuration );
+
+            result = scmManager.changeLog( repository, fileSet, startDate, null, 0, null,
null );
+        }
+        else
+        {
+            result = scmManager.changeLog( repository, fileSet, scmVersion, scmVersion );
+        }
 
         return result;
     }
@@ -206,6 +219,21 @@ public class DefaultContinuumScm
         return repository;
     }
 
+    private Date getScmStartDate( ContinuumScmConfiguration configuration )
+    {
+        Date startDate = configuration.getLatestUpdateDate();
+
+        if ( startDate == null )
+        {
+            // start date defaults to January 1, 1970
+            Calendar cal = Calendar.getInstance();
+            cal.set( 1970, Calendar.JANUARY, 1 );
+            startDate = cal.getTime();
+        }
+
+        return startDate;
+    }
+
     public ScmManager getScmManager()
     {
         return scmManager;

Added: continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java?rev=1044989&view=auto
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
(added)
+++ continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/DefaultContinuumScmTest.java
Mon Dec 13 01:00:36 2010
@@ -0,0 +1,88 @@
+package org.apache.continuum.scm;
+
+import java.io.File;
+import java.util.Date;
+import junit.framework.TestCase;
+
+import org.apache.continuum.scm.manager.ScmManager;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.ScmBranch;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmVersion;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit3.JUnit3Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+
+public class DefaultContinuumScmTest
+    extends TestCase
+{
+    private ScmManager scmManager;
+
+    private DefaultContinuumScm continuumScm;
+
+    private Mockery context;
+
+    private ContinuumScmConfiguration config;
+
+    @Override
+    public void setUp()
+    {
+        context = new JUnit3Mockery();
+        context.setImposteriser( ClassImposteriser.INSTANCE );
+
+        scmManager = context.mock( ScmManager.class );
+
+        continuumScm = new DefaultContinuumScm();
+        continuumScm.setScmManager( scmManager );
+
+        config = getScmConfiguration();
+    }
+
+    public void testChangeLogWithScmVersion()
+        throws Exception
+    {
+        config.setTag( "1.0-SNAPSHOT" );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( scmManager ).makeScmRepository( config.getUrl() );
+                one( scmManager ).changeLog( with( any( ScmRepository.class ) ), with( any(
ScmFileSet.class ) ), 
+                                             with( any( ScmVersion.class ) ), with( any(
ScmVersion.class ) ) );
+            }
+        });
+
+        continuumScm.changeLog( config );
+
+        context.assertIsSatisfied();
+    }
+
+    public void testChangeLogWithNoScmVersion()
+        throws Exception
+    {
+        config.setTag( "" );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( scmManager ).makeScmRepository( config.getUrl() );
+                one( scmManager ).changeLog( with( any( ScmRepository.class ) ), with( any(
ScmFileSet.class ) ), 
+                                             with( any( Date.class ) ), with( aNull( Date.class)
), with( equal( 0 ) ), 
+                                             with( aNull( ScmBranch.class) ), with( aNull(
String.class ) ) );
+            }
+        });
+
+        continuumScm.changeLog( config );
+        context.assertIsSatisfied();
+    }
+
+    private ContinuumScmConfiguration getScmConfiguration()
+    {
+        ContinuumScmConfiguration config = new ContinuumScmConfiguration();
+        config.setWorkingDirectory( new File( "1" ) );
+        config.setUrl( "scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-clean-plugin"
);
+
+        return config;
+    }
+}

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ChangeLogProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ChangeLogProjectAction.java?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ChangeLogProjectAction.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ChangeLogProjectAction.java
Mon Dec 13 01:00:36 2010
@@ -60,6 +60,7 @@ public class ChangeLogProjectAction
         {
             File workingDirectory = buildAgentConfigurationService.getWorkingDirectory( project.getId()
);
             ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory
);
+            config.setLatestUpdateDate( ContinuumBuildAgentUtil.getLatestUpdateDate( context
) );
             getLogger().info( "Getting changeLog of project: " + project.getName() );
             ChangeLogScmResult changeLogResult = scm.changeLog( config );
 
@@ -91,6 +92,7 @@ public class ChangeLogProjectAction
         config.setUseCredentialsCache( project.isScmUseCache() );
         config.setWorkingDirectory( workingDirectory );
         config.setTag( project.getScmTag() );
+
         return config;
     }
 
@@ -123,4 +125,14 @@ public class ChangeLogProjectAction
 
         return null;
     }
+
+    public void setScm( ContinuumScm scm )
+    {
+        this.scm = scm;
+    }
+
+    public void setBuildAgentConfigurationService( BuildAgentConfigurationService buildAgentConfigurationService
)
+    {
+        this.buildAgentConfigurationService = buildAgentConfigurationService;
+    }
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java
Mon Dec 13 01:00:36 2010
@@ -125,7 +125,15 @@ public class UpdateWorkingDirectoryActio
         }
 
         context.put( ContinuumBuildAgentUtil.KEY_UPDATE_SCM_RESULT, result );
-        context.put( ContinuumBuildAgentUtil.KEY_LATEST_UPDATE_DATE, getLatestUpdateDate(
result ) );
+
+        Date latestUpdateDate = getLatestUpdateDate( result );
+
+        if ( latestUpdateDate == null )
+        {
+            latestUpdateDate = ContinuumBuildAgentUtil.getLatestUpdateDate( context );
+        }
+
+        context.put( ContinuumBuildAgentUtil.KEY_LATEST_UPDATE_DATE, latestUpdateDate );
     }
 
     private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory
)

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
Mon Dec 13 01:00:36 2010
@@ -22,7 +22,6 @@ package org.apache.continuum.buildagent.
 import java.util.Date;
 import java.util.Map;
 
-import org.apache.continuum.utils.build.BuildTrigger;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.scm.ScmResult;
 

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java
Mon Dec 13 01:00:36 2010
@@ -222,14 +222,6 @@ public class PrepareBuildProjectsTaskExe
             scmResult = ContinuumBuildAgentUtil.getUpdateScmResult( actionContext, null );
 
             date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
-
-            if ( date == null )
-            {
-                // try to get latest update date from change log because sometimes date in
the changefile is 0
-                performAction( "changelog-agent-project", buildContext );
-
-                date = ContinuumBuildAgentUtil.getLatestUpdateDate( actionContext );
-            }
         }
         else
         {

Modified: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java?rev=1044989&r1=1044988&r2=1044989&view=diff
==============================================================================
--- continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
(original)
+++ continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
Mon Dec 13 01:00:36 2010
@@ -167,7 +167,7 @@ public class DistributedBuildProjectTask
                 if ( buildResult != null )
                 {
                     context.put( ContinuumBuildConstant.KEY_LATEST_UPDATE_DATE,
-                                 new Date( buildResult.getStartTime() ) );
+                                 new Date( buildResult.getLastChangedDate() ) );
                 }
 
                 LocalRepository localRepo = project.getProjectGroup().getLocalRepository();
               



Mime
View raw message