-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCM-706 finer-grained handling of file rename status for gitexe provi…
…der, rename source is not added to the set of files for commit operation anymore
- Loading branch information
1 parent
c76eb1f
commit 8b8db48
Showing
4 changed files
with
94 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,6 @@ | |
* under the License. | ||
*/ | ||
|
||
import java.net.URI; | ||
|
||
import org.apache.maven.scm.ScmException; | ||
import org.apache.maven.scm.ScmFileSet; | ||
import org.apache.maven.scm.command.status.AbstractStatusCommand; | ||
|
@@ -32,6 +30,8 @@ | |
import org.codehaus.plexus.util.cli.CommandLineUtils; | ||
import org.codehaus.plexus.util.cli.Commandline; | ||
|
||
import java.net.URI; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Brett Porter</a> | ||
* | ||
|
@@ -41,7 +41,7 @@ public class GitStatusCommand | |
implements GitCommand | ||
{ | ||
/** {@inheritDoc} */ | ||
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) | ||
public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) | ||
throws ScmException | ||
{ | ||
Commandline clRevparse = createRevparseShowToplevelCommand( fileSet ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,19 +19,19 @@ | |
* under the License. | ||
*/ | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.maven.scm.ScmFile; | ||
import org.apache.maven.scm.ScmFileStatus; | ||
import org.apache.maven.scm.log.ScmLogger; | ||
import org.codehaus.plexus.util.cli.StreamConsumer; | ||
|
||
import java.io.File; | ||
import java.net.URI; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.maven.scm.ScmFile; | ||
import org.apache.maven.scm.ScmFileStatus; | ||
import org.apache.maven.scm.log.ScmLogger; | ||
import org.codehaus.plexus.util.cli.StreamConsumer; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Mark Struberg</a> | ||
*/ | ||
|
@@ -123,33 +123,36 @@ public void consumeLine( String line ) | |
return; | ||
} | ||
|
||
ScmFileStatus status = null; | ||
ScmFileStatus statusFrom = null; | ||
ScmFileStatus statusTo = null; | ||
|
||
String fileFrom = null; | ||
String fileTo = null; | ||
|
||
List<String> files = new ArrayList<String>(); | ||
|
||
Matcher matcher; | ||
if ( ( matcher = ADDED_PATTERN.matcher( line ) ).find() ) | ||
{ | ||
status = ScmFileStatus.ADDED; | ||
files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); | ||
statusTo = ScmFileStatus.ADDED; | ||
fileTo = resolvePath( matcher.group( 1 ), relativeRepositoryPath ); | ||
} | ||
else if ( ( matcher = MODIFIED_PATTERN.matcher( line ) ).find() ) | ||
{ | ||
status = ScmFileStatus.MODIFIED; | ||
files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); | ||
statusTo = ScmFileStatus.MODIFIED; | ||
fileTo = resolvePath( matcher.group( 1 ), relativeRepositoryPath ); | ||
} | ||
else if ( ( matcher = DELETED_PATTERN.matcher( line ) ).find() ) | ||
{ | ||
status = ScmFileStatus.DELETED; | ||
files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); | ||
statusTo = ScmFileStatus.DELETED; | ||
fileTo = resolvePath( matcher.group( 1 ), relativeRepositoryPath ); | ||
} | ||
else if ( ( matcher = RENAMED_PATTERN.matcher( line ) ).find() ) | ||
{ | ||
status = ScmFileStatus.RENAMED; | ||
files.add( resolvePath( matcher.group( 1 ), relativeRepositoryPath ) ); | ||
files.add( resolvePath( matcher.group( 2 ), relativeRepositoryPath ) ); | ||
statusFrom = ScmFileStatus.RENAMED_FROM; | ||
fileFrom = resolvePath( matcher.group( 1 ), relativeRepositoryPath ); | ||
statusTo = ScmFileStatus.RENAMED_TO; | ||
fileTo = resolvePath( matcher.group( 2 ), relativeRepositoryPath ); | ||
logger.debug( "RENAMED status for line '" + line + "' files added '" + matcher.group( 1 ) + "' '" | ||
+ matcher.group( 2 ) ); | ||
+ matcher.group( 2 ) ); | ||
} | ||
else | ||
{ | ||
|
@@ -158,54 +161,50 @@ else if ( ( matcher = RENAMED_PATTERN.matcher( line ) ).find() ) | |
} | ||
|
||
// If the file isn't a file; don't add it. | ||
if ( !files.isEmpty() && status != null ) | ||
if ( workingDirectory != null ) | ||
{ | ||
if ( workingDirectory != null ) | ||
if ( statusTo == ScmFileStatus.RENAMED_TO ) | ||
{ | ||
if ( status == ScmFileStatus.RENAMED ) | ||
if ( isFile( fileFrom ) ) | ||
{ | ||
String oldFilePath = files.get( 0 ); | ||
String newFilePath = files.get( 1 ); | ||
if ( isFile( oldFilePath ) ) | ||
{ | ||
logger.debug( "file '" + oldFilePath + "' is a file" ); | ||
return; | ||
} | ||
else | ||
{ | ||
logger.debug( "file '" + oldFilePath + "' not a file" ); | ||
} | ||
if ( !isFile( newFilePath ) ) | ||
{ | ||
logger.debug( "file '" + newFilePath + "' not a file" ); | ||
return; | ||
} | ||
else | ||
{ | ||
logger.debug( "file '" + newFilePath + "' is a file" ); | ||
} | ||
logger.debug( "file '" + fileFrom + "' is a file" ); | ||
return; | ||
} | ||
else if ( status == ScmFileStatus.DELETED ) | ||
else | ||
{ | ||
logger.debug( "file '" + fileFrom + "' not a file" ); | ||
} | ||
if ( !isFile( fileTo ) ) | ||
{ | ||
if ( isFile( files.get( 0 ) ) ) | ||
{ | ||
return; | ||
} | ||
logger.debug( "file '" + fileTo + "' not a file" ); | ||
return; | ||
} | ||
else | ||
{ | ||
if ( !isFile( files.get( 0 ) ) ) | ||
{ | ||
return; | ||
} | ||
logger.debug( "file '" + fileTo + "' is a file" ); | ||
} | ||
} | ||
|
||
for ( String file : files ) | ||
else if ( statusTo == ScmFileStatus.DELETED ) | ||
{ | ||
changedFiles.add( new ScmFile( file, status ) ); | ||
if ( isFile( fileTo ) ) | ||
{ | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
if ( !isFile( fileTo ) ) | ||
{ | ||
return; | ||
} | ||
} | ||
} | ||
|
||
if ( statusFrom != null ) | ||
{ | ||
changedFiles.add( new ScmFile( fileFrom, statusFrom ) ); | ||
} | ||
changedFiles.add( new ScmFile( fileTo, statusTo ) ); | ||
} | ||
|
||
private boolean isFile( String file ) | ||
|