Skip to content
Commits on Source (2)
......@@ -6,3 +6,4 @@
*.css text
*.js text
*.sql text
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
asfMavenTlpStdBuild()
......@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm</artifactId>
<version>1.9.5</version>
<version>1.11.1</version>
</parent>
<artifactId>maven-scm-api</artifactId>
......
......@@ -34,6 +34,8 @@ public class CommandParameter
public static final CommandParameter RECURSIVE = new CommandParameter( "recursive" );
public static final CommandParameter SHALLOW = new CommandParameter( "shallow" );
public static final CommandParameter MESSAGE = new CommandParameter( "message" );
public static final CommandParameter BRANCH_NAME = new CommandParameter( "branchName" );
......
......@@ -394,10 +394,10 @@ private void setObject( CommandParameter parameter, Object value )
/**
* Removes a parameter, silent if it didn't exist.
*
* @param parameter name of the parameter to remove
* @param parameter to remove
*/
public void remove( CommandParameter parameter )
{
parameters.remove( parameter );
parameters.remove( parameter.getName() );
}
}
......@@ -34,11 +34,14 @@ public class ScmBranchParameters
private boolean remoteBranching = false;
private boolean pinExternals = false;
private String scmRevision;
public ScmBranchParameters()
{
this.remoteBranching = false;
this.pinExternals = false;
}
public ScmBranchParameters( String message )
......@@ -76,6 +79,16 @@ public void setRemoteBranching( boolean remoteBranching )
this.remoteBranching = remoteBranching;
}
public boolean isPinExternals()
{
return pinExternals;
}
public void setPinExternals( boolean pinExternals )
{
this.pinExternals = pinExternals;
}
public String toString()
{
return "[" + scmRevision + "] " + message;
......
......@@ -102,8 +102,7 @@ public ScmFileSet( File basedir, String includes, String excludes )
{
excludes = DEFAULT_EXCLUDES;
}
@SuppressWarnings( "unchecked" )
List<File> fileList = (List<File>) FileUtils.getFiles( basedir, includes, excludes, false );
List<File> fileList = FileUtils.getFiles( basedir, includes, excludes, false );
this.files = fileList;
this.includes = includes;
this.excludes = excludes;
......
......@@ -44,7 +44,7 @@ public class ScmResult
public static final String PASSWORD_PLACE_HOLDER = "********";
//works for SVN and git
private Pattern patternForUserColonPasswordAtHost = Pattern.compile( "^.*:(.*)@.*$" );
private Pattern patternForUserColonPasswordAtHost = Pattern.compile( "^.*:(.*)@.*$", Pattern.DOTALL );
/**
* Copy constructor.
......
......@@ -34,11 +34,17 @@ public class ScmTagParameters
private boolean remoteTagging = false;
private boolean pinExternals = false;
private boolean sign = false;
private String scmRevision;
public ScmTagParameters()
{
this.remoteTagging = false;
this.pinExternals = false;
this.sign = false;
}
public ScmTagParameters( String message )
......@@ -66,6 +72,26 @@ public void setRemoteTagging( boolean remoteTagging )
this.remoteTagging = remoteTagging;
}
public boolean isPinExternals()
{
return pinExternals;
}
public void setPinExternals( boolean pinExternals )
{
this.pinExternals = pinExternals;
}
public boolean isSign()
{
return sign;
}
public void setSign( boolean sign )
{
this.sign = sign;
}
public String getScmRevision()
{
return scmRevision;
......
......@@ -55,6 +55,14 @@ protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo
throw new ScmException( "Unsupported method for this provider." );
}
@Deprecated
protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet,
ScmVersion version, String datePattern )
throws ScmException
{
throw new ScmException( "Unsupported method for this provider." );
}
/**
* {@inheritDoc}
*/
......@@ -76,13 +84,21 @@ public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fi
ScmBranch branch = (ScmBranch) parameters.getScmVersion( CommandParameter.BRANCH, null );
ScmVersion version = parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
ScmVersion startVersion = parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null );
ScmVersion endVersion = parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null );
String datePattern = parameters.getString( CommandParameter.CHANGELOG_DATE_PATTERN, null );
if ( startVersion != null || endVersion != null )
boolean versionOnly = startVersion == null && endVersion == null && version != null;
if ( versionOnly )
{
return executeChangeLogCommand( repository, fileSet, version, datePattern );
}
else if ( startVersion != null || endVersion != null )
{
return executeChangeLogCommand( repository, fileSet, startVersion, endVersion, datePattern );
}
......
......@@ -175,4 +175,15 @@ public void setDateRange( Date startDate, Date endDate )
setEndDate( endDate );
}
public void setRevision( ScmVersion revision )
throws ScmException
{
parameters.setScmVersion( CommandParameter.SCM_VERSION, revision );
}
public ScmVersion getRevision()
throws ScmException
{
return parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
}
}
......@@ -45,13 +45,13 @@ public abstract class AbstractCheckOutCommand
* @param scmVersion not null
* @return the checkout result
* @throws ScmException if any
* @see #executeCheckOutCommand(ScmProviderRepository, ScmFileSet, ScmVersion, boolean)
* @see #executeCheckOutCommand(ScmProviderRepository, ScmFileSet, ScmVersion, boolean, boolean)
*/
protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repository, ScmFileSet fileSet,
ScmVersion scmVersion )
throws ScmException
{
return executeCheckOutCommand( repository, fileSet, scmVersion, true );
return executeCheckOutCommand( repository, fileSet, scmVersion, true, false );
}
/**
......@@ -61,12 +61,14 @@ protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository reposi
* @param fileSet not null
* @param scmVersion not null
* @param recursive <code>true</code> if recursive check out is wanted, <code>false</code> otherwise.
* @param shallow <code>true</code> if shallow check out is wanted, <code>false</code> otherwise.
* @return the checkout result
* @throws ScmException if any
* @since 1.1.1
*/
protected abstract CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repository, ScmFileSet fileSet,
ScmVersion scmVersion, boolean recursive )
ScmVersion scmVersion, boolean recursive,
boolean shallow )
throws ScmException;
/** {@inheritDoc} */
......@@ -75,13 +77,8 @@ public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fi
throws ScmException
{
ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
String recursiveParam = parameters.getString( CommandParameter.RECURSIVE, null );
if ( recursiveParam != null )
{
boolean recursive = parameters.getBoolean( CommandParameter.RECURSIVE );
return executeCheckOutCommand( repository, fileSet, scmVersion, recursive );
}
return executeCheckOutCommand( repository, fileSet, scmVersion );
boolean recursive = parameters.getBoolean( CommandParameter.RECURSIVE, true );
boolean shallow = parameters.getBoolean( CommandParameter.SHALLOW, false );
return executeCheckOutCommand( repository, fileSet, scmVersion, recursive, shallow );
}
}
......@@ -167,9 +167,12 @@ public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandPa
{
login( repository, fileSet );
if ( parameters.getString( CommandParameter.BINARY , null ) == null )
{
// TODO: binary may be dependant on particular files though
// TODO: set boolean?
parameters.setString( CommandParameter.BINARY, "false" );
}
return add( repository.getProviderRepository(), fileSet, parameters );
}
......@@ -497,6 +500,20 @@ public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet,
return checkout( repository.getProviderRepository(), fileSet, parameters );
}
@Override
public CheckOutScmResult checkOut( ScmRepository repository, ScmFileSet fileSet, ScmVersion scmVersion,
CommandParameters commandParameters )
throws ScmException
{
login( repository, fileSet );
if ( scmVersion != null && commandParameters.getScmVersion( CommandParameter.SCM_VERSION, null ) == null )
{
commandParameters.setScmVersion( CommandParameter.SCM_VERSION, scmVersion );
}
return checkout( repository.getProviderRepository(), fileSet, commandParameters );
}
protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
throws ScmException
......
......@@ -492,6 +492,22 @@ CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet,
boolean recursive )
throws ScmException;
/**
* Create a copy of the repository on your local machine.
*
* @param scmRepository the source control system
* @param scmFileSet the files are copied to the {@link org.apache.maven.scm.ScmFileSet#getBasedir()}
* location
* @param version get the version defined by the revision, branch or tag
* @param commandParameters parameters
* @return
* @throws ScmException if any
* @since 1.9.6
*/
CheckOutScmResult checkOut( ScmRepository scmRepository, ScmFileSet scmFileSet, ScmVersion version , //
CommandParameters commandParameters )
throws ScmException;
/**
* Create a diff between two branch/tag/revision.
*
......
......@@ -78,10 +78,20 @@ protected Date parseDate( String date, String userPattern, String defaultPattern
DateFormat format;
String patternUsed = null;
Locale localeUsed = null;
if ( StringUtils.isNotEmpty( userPattern ) )
{
if ( locale != null )
{
format = new SimpleDateFormat( userPattern, locale );
localeUsed = locale;
}
else
{
format = new SimpleDateFormat( userPattern );
localeUsed = Locale.getDefault();
}
patternUsed = userPattern;
}
else
......@@ -91,10 +101,12 @@ protected Date parseDate( String date, String userPattern, String defaultPattern
if ( locale != null )
{
format = new SimpleDateFormat( defaultPattern, locale );
localeUsed = locale;
}
else
{
format = new SimpleDateFormat( defaultPattern );
localeUsed = Locale.getDefault();
}
patternUsed = defaultPattern;
}
......@@ -102,8 +114,8 @@ protected Date parseDate( String date, String userPattern, String defaultPattern
{
// Use the English short date pattern if no pattern is specified
format = DateFormat.getDateInstance( DateFormat.SHORT, Locale.ENGLISH );
patternUsed = "DateFormat.SHORT";
localeUsed = Locale.ENGLISH;
}
}
......@@ -116,9 +128,9 @@ protected Date parseDate( String date, String userPattern, String defaultPattern
if ( getLogger() != null && getLogger().isWarnEnabled() )
{
getLogger().warn(
"skip ParseException: " + e.getMessage() + " during parsing date " + date
+ " with pattern " + patternUsed + " with Locale "
+ ( locale == null ? Locale.ENGLISH : locale ), e );
"skip ParseException: " + e.getMessage() + " during parsing date '" + date
+ "' with pattern '" + patternUsed + "' and locale '"
+ localeUsed + "'", e );
}
return null;
......
package org.apache.maven.scm.util;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import org.codehaus.plexus.util.cli.StreamConsumer;
/**
* @author <a href="mailto:davide.angelocola+apache@gmail.com">Davide Angelocola</a>
*/
public class ConsumerUtils
{
private ConsumerUtils()
{
}
/**
* Read file f, sending each line to the consumer.
*
* @param f
* @param consumer
* @throws IOException
*/
public static void consumeFile( File f, StreamConsumer consumer ) throws IOException
{
BufferedReader r = new BufferedReader( new FileReader( f ) );
try
{
String line;
while ( ( line = r.readLine() ) != null )
{
consumer.consumeLine( line );
}
}
finally
{
r.close();
}
}
}
......@@ -23,8 +23,6 @@
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse </a>
* @version $Id: ChangeLogFileTest.java,v 1.1.1.1 2004/04/20 19:05:52 jvanzyl
* Exp $
*/
public class ChangeFileTest
extends TestCase
......
......@@ -20,7 +20,6 @@
*/
import junit.framework.TestCase;
import org.apache.maven.scm.provider.ScmUrlUtils;
public class ScmResultTest
extends TestCase
......@@ -30,14 +29,20 @@ public class ScmResultTest
private static final String SCM_URL_GIT_COLON = "scm:git:https://username:" + PASSWORD + "@github.com/username/repo.git";
private static final String MOCK_ERROR_OUTPUT = "fatal repository " + SCM_URL_GIT_COLON + "does not exist";
private static final String MOCK_ERROR_OUTPUT = "fatal: repository '" + SCM_URL_GIT_COLON + "' not found";
private static final String MOCK_ERROR_MULTILINE_OUTPUT = "remote: Invalid username or password." + System.lineSeparator() + "fatal: Authentication failed for '" + SCM_URL_GIT_COLON + "'";
public void testPasswordsAreMaskedInOutput()
throws Exception
{
ScmResult result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_OUTPUT, false );
assertNotSame( "Command Output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput() );
assertTrue( "Command Output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER ) );
assertNotSame( "Command output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput() );
assertTrue( "Command output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER ) );
result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_MULTILINE_OUTPUT, false );
assertNotSame( "Command output contains password", MOCK_ERROR_MULTILINE_OUTPUT, result.getCommandOutput() );
assertTrue( "Command output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER ) );
}
}
......@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm</artifactId>
<version>1.9.5</version>
<version>1.11.1</version>
</parent>
<artifactId>maven-scm-client</artifactId>
......@@ -127,7 +127,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorId>jar-with-dependencies</descriptorId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>maven-scm-client-${project.version}</finalName>
<archive>
<manifestEntries>
......
......@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-managers</artifactId>
<version>1.9.5</version>
<version>1.11.1</version>
</parent>
<artifactId>maven-scm-manager-plexus</artifactId>
......