maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] michael-o closed pull request #36: Updated Jazz: StatusConsumer and fixed CommitCommand
Date Fri, 28 Dec 2018 13:10:36 GMT
michael-o closed pull request #36: Updated Jazz: StatusConsumer and fixed CommitCommand
URL: https://github.com/apache/maven-scm/pull/36
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
b/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
index 123cec874..b7625032d 100644
--- a/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
+++ b/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
@@ -142,7 +142,7 @@ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository
reposito
                     errConsumer = new ErrorConsumer( getLogger() );
         
                     status = changesetAssociateCmd.execute( outputConsumer, errConsumer );
-                    if ( status != 0 || errConsumer.hasBeenFed() )
+                    if ( status != 0  )
                     {
                         return new CheckInScmResult( changesetAssociateCmd.getCommandString(),
                                                      "Error code for Jazz SCM changeset associate
command - " + status,
diff --git a/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusConsumer.java
b/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusConsumer.java
index 19eba7aa8..63968a261 100644
--- a/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusConsumer.java
+++ b/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusConsumer.java
@@ -172,6 +172,7 @@
      * Implement a simple state machine: Have we seen the "Change sets:" line or not?
      */
     private boolean seenChangeSets = false;
+    private int sectionIndentation = 0;
 
     /**
      * Constructor for our "scm status" consumer.
@@ -193,6 +194,13 @@ public JazzStatusConsumer( ScmProviderRepository repo, ScmLogger logger
)
     public void consumeLine( String line )
     {
         super.consumeLine( line );
+        
+        // reset the state machine if text is at the same level or less than the changeSets
text
+        if ( seenChangeSets && getIndentation( line ) <= sectionIndentation )
+        {
+            seenChangeSets = false;
+        }
+            
         if ( containsWorkspace( line ) )
         {
             extractWorkspace( line );
@@ -212,6 +220,9 @@ public void consumeLine( String line )
         if ( containsChangeSets( line ) )
         {
             seenChangeSets = true;
+            // store the indentation of the line to know when the section is "closed" by
other text at the same 
+            // indentation level
+            sectionIndentation = getIndentation( line );
         }
         if ( seenChangeSets )
         {
@@ -219,6 +230,19 @@ public void consumeLine( String line )
         }
     }
 
+    
+    /**
+     * Determine the indentation (# whitespace characters) at the beginning of a line
+     * @param line
+     * @return # whitespace characters found, or 0 if none found.
+     */
+    private int getIndentation( String line )
+    {
+        // split on multiple whitespace
+        String[] lines = line.split( "^[\\s]+" );
+        return ( lines.length == 1 ) ? 0 : line.indexOf( lines[1] );
+    }
+    
     private boolean containsWorkspace( String line )
     {
         return line.trim().startsWith( STATUS_CMD_WORKSPACE );
diff --git a/maven-scm-providers/maven-scm-provider-jazz/src/test/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusCommandTest.java
b/maven-scm-providers/maven-scm-provider-jazz/src/test/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusCommandTest.java
index ede7e9161..e6a315356 100644
--- a/maven-scm-providers/maven-scm-provider-jazz/src/test/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusCommandTest.java
+++ b/maven-scm-providers/maven-scm-provider-jazz/src/test/java/org/apache/maven/scm/provider/jazz/command/status/JazzStatusCommandTest.java
@@ -232,7 +232,6 @@ public void testConsumerWithMultipleChangeSetsAndWorkItems()
     {
     	statusConsumer.consumeLine( "Workspace: (1000) \"GPDBWorkspace\" <-> (1001) \"GPDBStream\""
);
     	statusConsumer.consumeLine( "  Component: (1002) \"GPDB\"" );
-    	statusConsumer.consumeLine( "    Baseline: (1003) 49 \"GPDB-MAN-1.0.50\"" );
     	statusConsumer.consumeLine( "    Unresolved:" );
     	statusConsumer.consumeLine( "      a-- /GPDB/GPDBEAR/pom.xml.releaseBackup" );
     	statusConsumer.consumeLine( "      a-- /GPDB/GPDBResources/pom.xml.releaseBackup" );
@@ -254,6 +253,7 @@ public void testConsumerWithMultipleChangeSetsAndWorkItems()
     			+ "release of GPDB-1.0.51\" 02-May-2015 07:54 PM" );
     	statusConsumer.consumeLine( "        (1006) ---@  \"[maven-release-plugin] prepare "
     			+ "release GPDB-1.0.51\" 02-May-2015 09:33 PM" );
+        statusConsumer.consumeLine( "    Baseline: (1003) 49 \"GPDB-MAN-1.0.50\"" );
 
         // Test the additional collected data, Workspace, Component, Baseline.
         assertEquals( "Workspace is incorrect!", "GPDBWorkspace", repo.getWorkspace() );


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message