Fix for MPCHANGELOG-34.

Plugin does not find the password for the CVSROOT in .cvspass if the CVSROOT in .cvspass is preceded by a "/1".


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115740 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dion committed 2004-07-09 11:53:46 +00:00
1 parent e15bbcdac1
commit 6d8ecab1a8
4 files changed
+145 -2

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@
<pomVersion>3</pomVersion>
<id>maven-changelog-plugin</id>
<name>Maven Changelog Plugin</name>
<currentVersion>1.7</currentVersion>
<currentVersion>1.7.1-SNAPSHOT</currentVersion>
<description/>
<shortDescription>Produce SCM changelog reports</shortDescription>
<url>http://maven.apache.org/reference/plugins/changelog/</url>
@@ -21,9 +21,11 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tools.ant.util.StringUtils;
import org.netbeans.lib.cvsclient.CVSRoot;
import org.netbeans.lib.cvsclient.Client;
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
@@ -226,11 +228,24 @@ public class CvsConnection
try
{
StringBuffer cvsroot = new StringBuffer();
reader = new BufferedReader(new FileReader(passFile));
String line;
while ((line = reader.readLine()) != null)
{
if (line.startsWith(cvsRoot))
if (line.startsWith("/"))
{
Vector cvspass = StringUtils.split(line, ' ');
if (cvspass.size() >= 3)
{
if (compareCvsRoot(cvsRoot, (String)cvspass.get(1))) {
password = (String)cvspass.get(2);
break;
}
}
}
else if (line.startsWith(cvsRoot))
{
password = line.substring(cvsRoot.length() + 1);
break;
@@ -263,6 +278,38 @@ public class CvsConnection
return password;
}
static boolean compareCvsRoot(String cvsRoot, String target)
{
String s1 = completeCvsRootPort(cvsRoot);
String s2 = completeCvsRootPort(target);
if (s1 != null && s1.equals(s2))
{
return true;
}
return false;
}
private static String completeCvsRootPort(String cvsRoot)
{
String result = cvsRoot;
int idx = cvsRoot.indexOf(':');
for (int i=0; i < 2 && idx != -1; i++)
{
idx = cvsRoot.indexOf(':', idx+1);
}
if (idx != -1 && cvsRoot.charAt(idx+1) == '/')
{
StringBuffer sb = new StringBuffer();
sb.append(cvsRoot.substring(0, idx+1));
sb.append("2401");
sb.append(cvsRoot.substring(idx+1));
result = sb.toString();
}
return result;
}
/**
* Process the CVS command passed in args[] array with all necessary
* options. The only difference from main() method is, that this method
@@ -0,0 +1,93 @@
package org.apache.maven.cvslib;
/* ====================================================================
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed 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.FileInputStream;
import java.util.Collection;
import java.util.Iterator;
import junit.framework.TestCase;
import org.apache.maven.changelog.ChangeLogEntry;
/**
* Test cases for {@link CvsConnection}
* @author
* @version $Id: CvsConnectionTest.java,v 1.3 2004/07/09 11:53:45 dion Exp $
*/
public class CvsConnectionTest extends TestCase
{
/** the {@link CvsConnection} used for testing */
private CvsConnection instance;
/** test data */
private String testData = ":pserver:user@server:/home/cvs";
private String[] testTrueData = {
":pserver:user@server:/home/cvs",
":pserver:user@server:2401/home/cvs"
};
private String[] testFalseData = {
":ext:user@server:/home/cvs",
":pserver:admin@server:/home/cvs",
":pserver:user@host:/home/cvs",
":pserver:user@server:/home/cvsroot",
":ext:user@server:2401/home/cvs",
":pserver:admin@server:2401/home/cvs",
":pserver:user@host:2401/home/cvs",
":pserver:user@server:2401/home/cvsroot"
};
/**
* Create a test with the given name
* @param testName the name of the test
*/
public CvsConnectionTest(String testName)
{
super(testName);
}
/**
* Test of compareCvsRoot method
* @throws Exception when there is an unexpected problem
*/
public void testCompareTrue() throws Exception
{
for (int i=0; i < testTrueData.length; i++) {
assertTrue(CvsConnection.compareCvsRoot(testData, testTrueData[i]));
}
}
/**
* Test of compareCvsRoot method
* @throws Exception when there is an unexpected problem
*/
public void testCompareFalse() throws Exception
{
for (int i=0; i < testFalseData.length; i++) {
assertFalse(CvsConnection.compareCvsRoot(testData, testFalseData[i]));
}
}
// Add test methods here, they have to start with 'test' name.
// for example:
// public void testHello() {}
}
+3
View File
@@ -25,6 +25,9 @@
<author email="evenisse@ifrance.com">Emmanuel Venisse</author>
</properties>
<body>
<release version="1.7.1-SNAPSHOT" date="in CVS">
<action dev="dion" type="fix" issue="MPCHANGELOG-34" due-to="Saito Kazuo">Plugin does not find the password for the CVSROOT in .cvspass if the CVSROOT in .cvspass is preceded by a "/1".</action>
</release>
<release version="1.7" date="2004-07-08">
<action dev="evenisse" type="fix">Add the possibility to specify a date format for input stream (Starteam only).</action>
</release>